1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package datatransfer
18
19 import (
20 "bytes"
21 "context"
22 "fmt"
23 "io"
24 "math"
25 "net/http"
26 "net/url"
27 "time"
28
29 datatransferpb "cloud.google.com/go/bigquery/datatransfer/apiv1/datatransferpb"
30 gax "github.com/googleapis/gax-go/v2"
31 "google.golang.org/api/googleapi"
32 "google.golang.org/api/iterator"
33 "google.golang.org/api/option"
34 "google.golang.org/api/option/internaloption"
35 gtransport "google.golang.org/api/transport/grpc"
36 httptransport "google.golang.org/api/transport/http"
37 locationpb "google.golang.org/genproto/googleapis/cloud/location"
38 "google.golang.org/grpc"
39 "google.golang.org/grpc/codes"
40 "google.golang.org/protobuf/encoding/protojson"
41 "google.golang.org/protobuf/proto"
42 )
43
44 var newClientHook clientHook
45
46
47 type CallOptions struct {
48 GetDataSource []gax.CallOption
49 ListDataSources []gax.CallOption
50 CreateTransferConfig []gax.CallOption
51 UpdateTransferConfig []gax.CallOption
52 DeleteTransferConfig []gax.CallOption
53 GetTransferConfig []gax.CallOption
54 ListTransferConfigs []gax.CallOption
55 ScheduleTransferRuns []gax.CallOption
56 StartManualTransferRuns []gax.CallOption
57 GetTransferRun []gax.CallOption
58 DeleteTransferRun []gax.CallOption
59 ListTransferRuns []gax.CallOption
60 ListTransferLogs []gax.CallOption
61 CheckValidCreds []gax.CallOption
62 EnrollDataSources []gax.CallOption
63 UnenrollDataSources []gax.CallOption
64 GetLocation []gax.CallOption
65 ListLocations []gax.CallOption
66 }
67
68 func defaultGRPCClientOptions() []option.ClientOption {
69 return []option.ClientOption{
70 internaloption.WithDefaultEndpoint("bigquerydatatransfer.googleapis.com:443"),
71 internaloption.WithDefaultEndpointTemplate("bigquerydatatransfer.UNIVERSE_DOMAIN:443"),
72 internaloption.WithDefaultMTLSEndpoint("bigquerydatatransfer.mtls.googleapis.com:443"),
73 internaloption.WithDefaultUniverseDomain("googleapis.com"),
74 internaloption.WithDefaultAudience("https://bigquerydatatransfer.googleapis.com/"),
75 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
76 internaloption.EnableJwtWithScope(),
77 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
78 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
79 }
80 }
81
82 func defaultCallOptions() *CallOptions {
83 return &CallOptions{
84 GetDataSource: []gax.CallOption{
85 gax.WithTimeout(20000 * time.Millisecond),
86 gax.WithRetry(func() gax.Retryer {
87 return gax.OnCodes([]codes.Code{
88 codes.Unavailable,
89 codes.DeadlineExceeded,
90 }, gax.Backoff{
91 Initial: 100 * time.Millisecond,
92 Max: 60000 * time.Millisecond,
93 Multiplier: 1.30,
94 })
95 }),
96 },
97 ListDataSources: []gax.CallOption{
98 gax.WithTimeout(20000 * time.Millisecond),
99 gax.WithRetry(func() gax.Retryer {
100 return gax.OnCodes([]codes.Code{
101 codes.Unavailable,
102 codes.DeadlineExceeded,
103 }, gax.Backoff{
104 Initial: 100 * time.Millisecond,
105 Max: 60000 * time.Millisecond,
106 Multiplier: 1.30,
107 })
108 }),
109 },
110 CreateTransferConfig: []gax.CallOption{
111 gax.WithTimeout(30000 * time.Millisecond),
112 },
113 UpdateTransferConfig: []gax.CallOption{
114 gax.WithTimeout(30000 * time.Millisecond),
115 },
116 DeleteTransferConfig: []gax.CallOption{
117 gax.WithTimeout(20000 * time.Millisecond),
118 gax.WithRetry(func() gax.Retryer {
119 return gax.OnCodes([]codes.Code{
120 codes.Unavailable,
121 codes.DeadlineExceeded,
122 }, gax.Backoff{
123 Initial: 100 * time.Millisecond,
124 Max: 60000 * time.Millisecond,
125 Multiplier: 1.30,
126 })
127 }),
128 },
129 GetTransferConfig: []gax.CallOption{
130 gax.WithTimeout(20000 * time.Millisecond),
131 gax.WithRetry(func() gax.Retryer {
132 return gax.OnCodes([]codes.Code{
133 codes.Unavailable,
134 codes.DeadlineExceeded,
135 }, gax.Backoff{
136 Initial: 100 * time.Millisecond,
137 Max: 60000 * time.Millisecond,
138 Multiplier: 1.30,
139 })
140 }),
141 },
142 ListTransferConfigs: []gax.CallOption{
143 gax.WithTimeout(20000 * time.Millisecond),
144 gax.WithRetry(func() gax.Retryer {
145 return gax.OnCodes([]codes.Code{
146 codes.Unavailable,
147 codes.DeadlineExceeded,
148 }, gax.Backoff{
149 Initial: 100 * time.Millisecond,
150 Max: 60000 * time.Millisecond,
151 Multiplier: 1.30,
152 })
153 }),
154 },
155 ScheduleTransferRuns: []gax.CallOption{
156 gax.WithTimeout(30000 * time.Millisecond),
157 },
158 StartManualTransferRuns: []gax.CallOption{},
159 GetTransferRun: []gax.CallOption{
160 gax.WithTimeout(20000 * time.Millisecond),
161 gax.WithRetry(func() gax.Retryer {
162 return gax.OnCodes([]codes.Code{
163 codes.Unavailable,
164 codes.DeadlineExceeded,
165 }, gax.Backoff{
166 Initial: 100 * time.Millisecond,
167 Max: 60000 * time.Millisecond,
168 Multiplier: 1.30,
169 })
170 }),
171 },
172 DeleteTransferRun: []gax.CallOption{
173 gax.WithTimeout(20000 * time.Millisecond),
174 gax.WithRetry(func() gax.Retryer {
175 return gax.OnCodes([]codes.Code{
176 codes.Unavailable,
177 codes.DeadlineExceeded,
178 }, gax.Backoff{
179 Initial: 100 * time.Millisecond,
180 Max: 60000 * time.Millisecond,
181 Multiplier: 1.30,
182 })
183 }),
184 },
185 ListTransferRuns: []gax.CallOption{
186 gax.WithTimeout(20000 * time.Millisecond),
187 gax.WithRetry(func() gax.Retryer {
188 return gax.OnCodes([]codes.Code{
189 codes.Unavailable,
190 codes.DeadlineExceeded,
191 }, gax.Backoff{
192 Initial: 100 * time.Millisecond,
193 Max: 60000 * time.Millisecond,
194 Multiplier: 1.30,
195 })
196 }),
197 },
198 ListTransferLogs: []gax.CallOption{
199 gax.WithTimeout(20000 * time.Millisecond),
200 gax.WithRetry(func() gax.Retryer {
201 return gax.OnCodes([]codes.Code{
202 codes.Unavailable,
203 codes.DeadlineExceeded,
204 }, gax.Backoff{
205 Initial: 100 * time.Millisecond,
206 Max: 60000 * time.Millisecond,
207 Multiplier: 1.30,
208 })
209 }),
210 },
211 CheckValidCreds: []gax.CallOption{
212 gax.WithTimeout(20000 * time.Millisecond),
213 gax.WithRetry(func() gax.Retryer {
214 return gax.OnCodes([]codes.Code{
215 codes.Unavailable,
216 codes.DeadlineExceeded,
217 }, gax.Backoff{
218 Initial: 100 * time.Millisecond,
219 Max: 60000 * time.Millisecond,
220 Multiplier: 1.30,
221 })
222 }),
223 },
224 EnrollDataSources: []gax.CallOption{},
225 UnenrollDataSources: []gax.CallOption{},
226 GetLocation: []gax.CallOption{},
227 ListLocations: []gax.CallOption{},
228 }
229 }
230
231 func defaultRESTCallOptions() *CallOptions {
232 return &CallOptions{
233 GetDataSource: []gax.CallOption{
234 gax.WithTimeout(20000 * time.Millisecond),
235 gax.WithRetry(func() gax.Retryer {
236 return gax.OnHTTPCodes(gax.Backoff{
237 Initial: 100 * time.Millisecond,
238 Max: 60000 * time.Millisecond,
239 Multiplier: 1.30,
240 },
241 http.StatusServiceUnavailable,
242 http.StatusGatewayTimeout)
243 }),
244 },
245 ListDataSources: []gax.CallOption{
246 gax.WithTimeout(20000 * time.Millisecond),
247 gax.WithRetry(func() gax.Retryer {
248 return gax.OnHTTPCodes(gax.Backoff{
249 Initial: 100 * time.Millisecond,
250 Max: 60000 * time.Millisecond,
251 Multiplier: 1.30,
252 },
253 http.StatusServiceUnavailable,
254 http.StatusGatewayTimeout)
255 }),
256 },
257 CreateTransferConfig: []gax.CallOption{
258 gax.WithTimeout(30000 * time.Millisecond),
259 },
260 UpdateTransferConfig: []gax.CallOption{
261 gax.WithTimeout(30000 * time.Millisecond),
262 },
263 DeleteTransferConfig: []gax.CallOption{
264 gax.WithTimeout(20000 * time.Millisecond),
265 gax.WithRetry(func() gax.Retryer {
266 return gax.OnHTTPCodes(gax.Backoff{
267 Initial: 100 * time.Millisecond,
268 Max: 60000 * time.Millisecond,
269 Multiplier: 1.30,
270 },
271 http.StatusServiceUnavailable,
272 http.StatusGatewayTimeout)
273 }),
274 },
275 GetTransferConfig: []gax.CallOption{
276 gax.WithTimeout(20000 * time.Millisecond),
277 gax.WithRetry(func() gax.Retryer {
278 return gax.OnHTTPCodes(gax.Backoff{
279 Initial: 100 * time.Millisecond,
280 Max: 60000 * time.Millisecond,
281 Multiplier: 1.30,
282 },
283 http.StatusServiceUnavailable,
284 http.StatusGatewayTimeout)
285 }),
286 },
287 ListTransferConfigs: []gax.CallOption{
288 gax.WithTimeout(20000 * time.Millisecond),
289 gax.WithRetry(func() gax.Retryer {
290 return gax.OnHTTPCodes(gax.Backoff{
291 Initial: 100 * time.Millisecond,
292 Max: 60000 * time.Millisecond,
293 Multiplier: 1.30,
294 },
295 http.StatusServiceUnavailable,
296 http.StatusGatewayTimeout)
297 }),
298 },
299 ScheduleTransferRuns: []gax.CallOption{
300 gax.WithTimeout(30000 * time.Millisecond),
301 },
302 StartManualTransferRuns: []gax.CallOption{},
303 GetTransferRun: []gax.CallOption{
304 gax.WithTimeout(20000 * time.Millisecond),
305 gax.WithRetry(func() gax.Retryer {
306 return gax.OnHTTPCodes(gax.Backoff{
307 Initial: 100 * time.Millisecond,
308 Max: 60000 * time.Millisecond,
309 Multiplier: 1.30,
310 },
311 http.StatusServiceUnavailable,
312 http.StatusGatewayTimeout)
313 }),
314 },
315 DeleteTransferRun: []gax.CallOption{
316 gax.WithTimeout(20000 * time.Millisecond),
317 gax.WithRetry(func() gax.Retryer {
318 return gax.OnHTTPCodes(gax.Backoff{
319 Initial: 100 * time.Millisecond,
320 Max: 60000 * time.Millisecond,
321 Multiplier: 1.30,
322 },
323 http.StatusServiceUnavailable,
324 http.StatusGatewayTimeout)
325 }),
326 },
327 ListTransferRuns: []gax.CallOption{
328 gax.WithTimeout(20000 * time.Millisecond),
329 gax.WithRetry(func() gax.Retryer {
330 return gax.OnHTTPCodes(gax.Backoff{
331 Initial: 100 * time.Millisecond,
332 Max: 60000 * time.Millisecond,
333 Multiplier: 1.30,
334 },
335 http.StatusServiceUnavailable,
336 http.StatusGatewayTimeout)
337 }),
338 },
339 ListTransferLogs: []gax.CallOption{
340 gax.WithTimeout(20000 * time.Millisecond),
341 gax.WithRetry(func() gax.Retryer {
342 return gax.OnHTTPCodes(gax.Backoff{
343 Initial: 100 * time.Millisecond,
344 Max: 60000 * time.Millisecond,
345 Multiplier: 1.30,
346 },
347 http.StatusServiceUnavailable,
348 http.StatusGatewayTimeout)
349 }),
350 },
351 CheckValidCreds: []gax.CallOption{
352 gax.WithTimeout(20000 * time.Millisecond),
353 gax.WithRetry(func() gax.Retryer {
354 return gax.OnHTTPCodes(gax.Backoff{
355 Initial: 100 * time.Millisecond,
356 Max: 60000 * time.Millisecond,
357 Multiplier: 1.30,
358 },
359 http.StatusServiceUnavailable,
360 http.StatusGatewayTimeout)
361 }),
362 },
363 EnrollDataSources: []gax.CallOption{},
364 UnenrollDataSources: []gax.CallOption{},
365 GetLocation: []gax.CallOption{},
366 ListLocations: []gax.CallOption{},
367 }
368 }
369
370
371 type internalClient interface {
372 Close() error
373 setGoogleClientInfo(...string)
374 Connection() *grpc.ClientConn
375 GetDataSource(context.Context, *datatransferpb.GetDataSourceRequest, ...gax.CallOption) (*datatransferpb.DataSource, error)
376 ListDataSources(context.Context, *datatransferpb.ListDataSourcesRequest, ...gax.CallOption) *DataSourceIterator
377 CreateTransferConfig(context.Context, *datatransferpb.CreateTransferConfigRequest, ...gax.CallOption) (*datatransferpb.TransferConfig, error)
378 UpdateTransferConfig(context.Context, *datatransferpb.UpdateTransferConfigRequest, ...gax.CallOption) (*datatransferpb.TransferConfig, error)
379 DeleteTransferConfig(context.Context, *datatransferpb.DeleteTransferConfigRequest, ...gax.CallOption) error
380 GetTransferConfig(context.Context, *datatransferpb.GetTransferConfigRequest, ...gax.CallOption) (*datatransferpb.TransferConfig, error)
381 ListTransferConfigs(context.Context, *datatransferpb.ListTransferConfigsRequest, ...gax.CallOption) *TransferConfigIterator
382 ScheduleTransferRuns(context.Context, *datatransferpb.ScheduleTransferRunsRequest, ...gax.CallOption) (*datatransferpb.ScheduleTransferRunsResponse, error)
383 StartManualTransferRuns(context.Context, *datatransferpb.StartManualTransferRunsRequest, ...gax.CallOption) (*datatransferpb.StartManualTransferRunsResponse, error)
384 GetTransferRun(context.Context, *datatransferpb.GetTransferRunRequest, ...gax.CallOption) (*datatransferpb.TransferRun, error)
385 DeleteTransferRun(context.Context, *datatransferpb.DeleteTransferRunRequest, ...gax.CallOption) error
386 ListTransferRuns(context.Context, *datatransferpb.ListTransferRunsRequest, ...gax.CallOption) *TransferRunIterator
387 ListTransferLogs(context.Context, *datatransferpb.ListTransferLogsRequest, ...gax.CallOption) *TransferMessageIterator
388 CheckValidCreds(context.Context, *datatransferpb.CheckValidCredsRequest, ...gax.CallOption) (*datatransferpb.CheckValidCredsResponse, error)
389 EnrollDataSources(context.Context, *datatransferpb.EnrollDataSourcesRequest, ...gax.CallOption) error
390 UnenrollDataSources(context.Context, *datatransferpb.UnenrollDataSourcesRequest, ...gax.CallOption) error
391 GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
392 ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
393 }
394
395
396
397
398
399 type Client struct {
400
401 internalClient internalClient
402
403
404 CallOptions *CallOptions
405 }
406
407
408
409
410
411 func (c *Client) Close() error {
412 return c.internalClient.Close()
413 }
414
415
416
417
418 func (c *Client) setGoogleClientInfo(keyval ...string) {
419 c.internalClient.setGoogleClientInfo(keyval...)
420 }
421
422
423
424
425
426 func (c *Client) Connection() *grpc.ClientConn {
427 return c.internalClient.Connection()
428 }
429
430
431 func (c *Client) GetDataSource(ctx context.Context, req *datatransferpb.GetDataSourceRequest, opts ...gax.CallOption) (*datatransferpb.DataSource, error) {
432 return c.internalClient.GetDataSource(ctx, req, opts...)
433 }
434
435
436 func (c *Client) ListDataSources(ctx context.Context, req *datatransferpb.ListDataSourcesRequest, opts ...gax.CallOption) *DataSourceIterator {
437 return c.internalClient.ListDataSources(ctx, req, opts...)
438 }
439
440
441 func (c *Client) CreateTransferConfig(ctx context.Context, req *datatransferpb.CreateTransferConfigRequest, opts ...gax.CallOption) (*datatransferpb.TransferConfig, error) {
442 return c.internalClient.CreateTransferConfig(ctx, req, opts...)
443 }
444
445
446
447 func (c *Client) UpdateTransferConfig(ctx context.Context, req *datatransferpb.UpdateTransferConfigRequest, opts ...gax.CallOption) (*datatransferpb.TransferConfig, error) {
448 return c.internalClient.UpdateTransferConfig(ctx, req, opts...)
449 }
450
451
452
453 func (c *Client) DeleteTransferConfig(ctx context.Context, req *datatransferpb.DeleteTransferConfigRequest, opts ...gax.CallOption) error {
454 return c.internalClient.DeleteTransferConfig(ctx, req, opts...)
455 }
456
457
458 func (c *Client) GetTransferConfig(ctx context.Context, req *datatransferpb.GetTransferConfigRequest, opts ...gax.CallOption) (*datatransferpb.TransferConfig, error) {
459 return c.internalClient.GetTransferConfig(ctx, req, opts...)
460 }
461
462
463
464 func (c *Client) ListTransferConfigs(ctx context.Context, req *datatransferpb.ListTransferConfigsRequest, opts ...gax.CallOption) *TransferConfigIterator {
465 return c.internalClient.ListTransferConfigs(ctx, req, opts...)
466 }
467
468
469
470
471
472
473
474
475 func (c *Client) ScheduleTransferRuns(ctx context.Context, req *datatransferpb.ScheduleTransferRunsRequest, opts ...gax.CallOption) (*datatransferpb.ScheduleTransferRunsResponse, error) {
476 return c.internalClient.ScheduleTransferRuns(ctx, req, opts...)
477 }
478
479
480
481
482
483 func (c *Client) StartManualTransferRuns(ctx context.Context, req *datatransferpb.StartManualTransferRunsRequest, opts ...gax.CallOption) (*datatransferpb.StartManualTransferRunsResponse, error) {
484 return c.internalClient.StartManualTransferRuns(ctx, req, opts...)
485 }
486
487
488 func (c *Client) GetTransferRun(ctx context.Context, req *datatransferpb.GetTransferRunRequest, opts ...gax.CallOption) (*datatransferpb.TransferRun, error) {
489 return c.internalClient.GetTransferRun(ctx, req, opts...)
490 }
491
492
493 func (c *Client) DeleteTransferRun(ctx context.Context, req *datatransferpb.DeleteTransferRunRequest, opts ...gax.CallOption) error {
494 return c.internalClient.DeleteTransferRun(ctx, req, opts...)
495 }
496
497
498 func (c *Client) ListTransferRuns(ctx context.Context, req *datatransferpb.ListTransferRunsRequest, opts ...gax.CallOption) *TransferRunIterator {
499 return c.internalClient.ListTransferRuns(ctx, req, opts...)
500 }
501
502
503 func (c *Client) ListTransferLogs(ctx context.Context, req *datatransferpb.ListTransferLogsRequest, opts ...gax.CallOption) *TransferMessageIterator {
504 return c.internalClient.ListTransferLogs(ctx, req, opts...)
505 }
506
507
508
509 func (c *Client) CheckValidCreds(ctx context.Context, req *datatransferpb.CheckValidCredsRequest, opts ...gax.CallOption) (*datatransferpb.CheckValidCredsResponse, error) {
510 return c.internalClient.CheckValidCreds(ctx, req, opts...)
511 }
512
513
514
515
516
517
518
519
520
521 func (c *Client) EnrollDataSources(ctx context.Context, req *datatransferpb.EnrollDataSourcesRequest, opts ...gax.CallOption) error {
522 return c.internalClient.EnrollDataSources(ctx, req, opts...)
523 }
524
525
526
527
528
529
530 func (c *Client) UnenrollDataSources(ctx context.Context, req *datatransferpb.UnenrollDataSourcesRequest, opts ...gax.CallOption) error {
531 return c.internalClient.UnenrollDataSources(ctx, req, opts...)
532 }
533
534
535 func (c *Client) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
536 return c.internalClient.GetLocation(ctx, req, opts...)
537 }
538
539
540 func (c *Client) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
541 return c.internalClient.ListLocations(ctx, req, opts...)
542 }
543
544
545
546
547 type gRPCClient struct {
548
549 connPool gtransport.ConnPool
550
551
552 CallOptions **CallOptions
553
554
555 client datatransferpb.DataTransferServiceClient
556
557 locationsClient locationpb.LocationsClient
558
559
560 xGoogHeaders []string
561 }
562
563
564
565
566
567 func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
568 clientOpts := defaultGRPCClientOptions()
569 if newClientHook != nil {
570 hookOpts, err := newClientHook(ctx, clientHookParams{})
571 if err != nil {
572 return nil, err
573 }
574 clientOpts = append(clientOpts, hookOpts...)
575 }
576
577 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
578 if err != nil {
579 return nil, err
580 }
581 client := Client{CallOptions: defaultCallOptions()}
582
583 c := &gRPCClient{
584 connPool: connPool,
585 client: datatransferpb.NewDataTransferServiceClient(connPool),
586 CallOptions: &client.CallOptions,
587 locationsClient: locationpb.NewLocationsClient(connPool),
588 }
589 c.setGoogleClientInfo()
590
591 client.internalClient = c
592
593 return &client, nil
594 }
595
596
597
598
599
600 func (c *gRPCClient) Connection() *grpc.ClientConn {
601 return c.connPool.Conn()
602 }
603
604
605
606
607 func (c *gRPCClient) setGoogleClientInfo(keyval ...string) {
608 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
609 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version)
610 c.xGoogHeaders = []string{"x-goog-api-client", gax.XGoogHeader(kv...)}
611 }
612
613
614
615 func (c *gRPCClient) Close() error {
616 return c.connPool.Close()
617 }
618
619
620 type restClient struct {
621
622 endpoint string
623
624
625 httpClient *http.Client
626
627
628 xGoogHeaders []string
629
630
631 CallOptions **CallOptions
632 }
633
634
635
636
637 func NewRESTClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
638 clientOpts := append(defaultRESTClientOptions(), opts...)
639 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
640 if err != nil {
641 return nil, err
642 }
643
644 callOpts := defaultRESTCallOptions()
645 c := &restClient{
646 endpoint: endpoint,
647 httpClient: httpClient,
648 CallOptions: &callOpts,
649 }
650 c.setGoogleClientInfo()
651
652 return &Client{internalClient: c, CallOptions: callOpts}, nil
653 }
654
655 func defaultRESTClientOptions() []option.ClientOption {
656 return []option.ClientOption{
657 internaloption.WithDefaultEndpoint("https://bigquerydatatransfer.googleapis.com"),
658 internaloption.WithDefaultEndpointTemplate("https://bigquerydatatransfer.UNIVERSE_DOMAIN"),
659 internaloption.WithDefaultMTLSEndpoint("https://bigquerydatatransfer.mtls.googleapis.com"),
660 internaloption.WithDefaultUniverseDomain("googleapis.com"),
661 internaloption.WithDefaultAudience("https://bigquerydatatransfer.googleapis.com/"),
662 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
663 }
664 }
665
666
667
668
669 func (c *restClient) setGoogleClientInfo(keyval ...string) {
670 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
671 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
672 c.xGoogHeaders = []string{"x-goog-api-client", gax.XGoogHeader(kv...)}
673 }
674
675
676
677 func (c *restClient) Close() error {
678
679 c.httpClient = nil
680 return nil
681 }
682
683
684
685
686 func (c *restClient) Connection() *grpc.ClientConn {
687 return nil
688 }
689 func (c *gRPCClient) GetDataSource(ctx context.Context, req *datatransferpb.GetDataSourceRequest, opts ...gax.CallOption) (*datatransferpb.DataSource, error) {
690 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
691
692 hds = append(c.xGoogHeaders, hds...)
693 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
694 opts = append((*c.CallOptions).GetDataSource[0:len((*c.CallOptions).GetDataSource):len((*c.CallOptions).GetDataSource)], opts...)
695 var resp *datatransferpb.DataSource
696 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
697 var err error
698 resp, err = c.client.GetDataSource(ctx, req, settings.GRPC...)
699 return err
700 }, opts...)
701 if err != nil {
702 return nil, err
703 }
704 return resp, nil
705 }
706
707 func (c *gRPCClient) ListDataSources(ctx context.Context, req *datatransferpb.ListDataSourcesRequest, opts ...gax.CallOption) *DataSourceIterator {
708 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
709
710 hds = append(c.xGoogHeaders, hds...)
711 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
712 opts = append((*c.CallOptions).ListDataSources[0:len((*c.CallOptions).ListDataSources):len((*c.CallOptions).ListDataSources)], opts...)
713 it := &DataSourceIterator{}
714 req = proto.Clone(req).(*datatransferpb.ListDataSourcesRequest)
715 it.InternalFetch = func(pageSize int, pageToken string) ([]*datatransferpb.DataSource, string, error) {
716 resp := &datatransferpb.ListDataSourcesResponse{}
717 if pageToken != "" {
718 req.PageToken = pageToken
719 }
720 if pageSize > math.MaxInt32 {
721 req.PageSize = math.MaxInt32
722 } else if pageSize != 0 {
723 req.PageSize = int32(pageSize)
724 }
725 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
726 var err error
727 resp, err = c.client.ListDataSources(ctx, req, settings.GRPC...)
728 return err
729 }, opts...)
730 if err != nil {
731 return nil, "", err
732 }
733
734 it.Response = resp
735 return resp.GetDataSources(), resp.GetNextPageToken(), nil
736 }
737 fetch := func(pageSize int, pageToken string) (string, error) {
738 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
739 if err != nil {
740 return "", err
741 }
742 it.items = append(it.items, items...)
743 return nextPageToken, nil
744 }
745
746 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
747 it.pageInfo.MaxSize = int(req.GetPageSize())
748 it.pageInfo.Token = req.GetPageToken()
749
750 return it
751 }
752
753 func (c *gRPCClient) CreateTransferConfig(ctx context.Context, req *datatransferpb.CreateTransferConfigRequest, opts ...gax.CallOption) (*datatransferpb.TransferConfig, error) {
754 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
755
756 hds = append(c.xGoogHeaders, hds...)
757 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
758 opts = append((*c.CallOptions).CreateTransferConfig[0:len((*c.CallOptions).CreateTransferConfig):len((*c.CallOptions).CreateTransferConfig)], opts...)
759 var resp *datatransferpb.TransferConfig
760 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
761 var err error
762 resp, err = c.client.CreateTransferConfig(ctx, req, settings.GRPC...)
763 return err
764 }, opts...)
765 if err != nil {
766 return nil, err
767 }
768 return resp, nil
769 }
770
771 func (c *gRPCClient) UpdateTransferConfig(ctx context.Context, req *datatransferpb.UpdateTransferConfigRequest, opts ...gax.CallOption) (*datatransferpb.TransferConfig, error) {
772 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "transfer_config.name", url.QueryEscape(req.GetTransferConfig().GetName()))}
773
774 hds = append(c.xGoogHeaders, hds...)
775 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
776 opts = append((*c.CallOptions).UpdateTransferConfig[0:len((*c.CallOptions).UpdateTransferConfig):len((*c.CallOptions).UpdateTransferConfig)], opts...)
777 var resp *datatransferpb.TransferConfig
778 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
779 var err error
780 resp, err = c.client.UpdateTransferConfig(ctx, req, settings.GRPC...)
781 return err
782 }, opts...)
783 if err != nil {
784 return nil, err
785 }
786 return resp, nil
787 }
788
789 func (c *gRPCClient) DeleteTransferConfig(ctx context.Context, req *datatransferpb.DeleteTransferConfigRequest, opts ...gax.CallOption) error {
790 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
791
792 hds = append(c.xGoogHeaders, hds...)
793 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
794 opts = append((*c.CallOptions).DeleteTransferConfig[0:len((*c.CallOptions).DeleteTransferConfig):len((*c.CallOptions).DeleteTransferConfig)], opts...)
795 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
796 var err error
797 _, err = c.client.DeleteTransferConfig(ctx, req, settings.GRPC...)
798 return err
799 }, opts...)
800 return err
801 }
802
803 func (c *gRPCClient) GetTransferConfig(ctx context.Context, req *datatransferpb.GetTransferConfigRequest, opts ...gax.CallOption) (*datatransferpb.TransferConfig, error) {
804 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
805
806 hds = append(c.xGoogHeaders, hds...)
807 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
808 opts = append((*c.CallOptions).GetTransferConfig[0:len((*c.CallOptions).GetTransferConfig):len((*c.CallOptions).GetTransferConfig)], opts...)
809 var resp *datatransferpb.TransferConfig
810 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
811 var err error
812 resp, err = c.client.GetTransferConfig(ctx, req, settings.GRPC...)
813 return err
814 }, opts...)
815 if err != nil {
816 return nil, err
817 }
818 return resp, nil
819 }
820
821 func (c *gRPCClient) ListTransferConfigs(ctx context.Context, req *datatransferpb.ListTransferConfigsRequest, opts ...gax.CallOption) *TransferConfigIterator {
822 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
823
824 hds = append(c.xGoogHeaders, hds...)
825 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
826 opts = append((*c.CallOptions).ListTransferConfigs[0:len((*c.CallOptions).ListTransferConfigs):len((*c.CallOptions).ListTransferConfigs)], opts...)
827 it := &TransferConfigIterator{}
828 req = proto.Clone(req).(*datatransferpb.ListTransferConfigsRequest)
829 it.InternalFetch = func(pageSize int, pageToken string) ([]*datatransferpb.TransferConfig, string, error) {
830 resp := &datatransferpb.ListTransferConfigsResponse{}
831 if pageToken != "" {
832 req.PageToken = pageToken
833 }
834 if pageSize > math.MaxInt32 {
835 req.PageSize = math.MaxInt32
836 } else if pageSize != 0 {
837 req.PageSize = int32(pageSize)
838 }
839 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
840 var err error
841 resp, err = c.client.ListTransferConfigs(ctx, req, settings.GRPC...)
842 return err
843 }, opts...)
844 if err != nil {
845 return nil, "", err
846 }
847
848 it.Response = resp
849 return resp.GetTransferConfigs(), resp.GetNextPageToken(), nil
850 }
851 fetch := func(pageSize int, pageToken string) (string, error) {
852 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
853 if err != nil {
854 return "", err
855 }
856 it.items = append(it.items, items...)
857 return nextPageToken, nil
858 }
859
860 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
861 it.pageInfo.MaxSize = int(req.GetPageSize())
862 it.pageInfo.Token = req.GetPageToken()
863
864 return it
865 }
866
867 func (c *gRPCClient) ScheduleTransferRuns(ctx context.Context, req *datatransferpb.ScheduleTransferRunsRequest, opts ...gax.CallOption) (*datatransferpb.ScheduleTransferRunsResponse, error) {
868 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
869
870 hds = append(c.xGoogHeaders, hds...)
871 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
872 opts = append((*c.CallOptions).ScheduleTransferRuns[0:len((*c.CallOptions).ScheduleTransferRuns):len((*c.CallOptions).ScheduleTransferRuns)], opts...)
873 var resp *datatransferpb.ScheduleTransferRunsResponse
874 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
875 var err error
876 resp, err = c.client.ScheduleTransferRuns(ctx, req, settings.GRPC...)
877 return err
878 }, opts...)
879 if err != nil {
880 return nil, err
881 }
882 return resp, nil
883 }
884
885 func (c *gRPCClient) StartManualTransferRuns(ctx context.Context, req *datatransferpb.StartManualTransferRunsRequest, opts ...gax.CallOption) (*datatransferpb.StartManualTransferRunsResponse, error) {
886 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
887
888 hds = append(c.xGoogHeaders, hds...)
889 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
890 opts = append((*c.CallOptions).StartManualTransferRuns[0:len((*c.CallOptions).StartManualTransferRuns):len((*c.CallOptions).StartManualTransferRuns)], opts...)
891 var resp *datatransferpb.StartManualTransferRunsResponse
892 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
893 var err error
894 resp, err = c.client.StartManualTransferRuns(ctx, req, settings.GRPC...)
895 return err
896 }, opts...)
897 if err != nil {
898 return nil, err
899 }
900 return resp, nil
901 }
902
903 func (c *gRPCClient) GetTransferRun(ctx context.Context, req *datatransferpb.GetTransferRunRequest, opts ...gax.CallOption) (*datatransferpb.TransferRun, error) {
904 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
905
906 hds = append(c.xGoogHeaders, hds...)
907 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
908 opts = append((*c.CallOptions).GetTransferRun[0:len((*c.CallOptions).GetTransferRun):len((*c.CallOptions).GetTransferRun)], opts...)
909 var resp *datatransferpb.TransferRun
910 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
911 var err error
912 resp, err = c.client.GetTransferRun(ctx, req, settings.GRPC...)
913 return err
914 }, opts...)
915 if err != nil {
916 return nil, err
917 }
918 return resp, nil
919 }
920
921 func (c *gRPCClient) DeleteTransferRun(ctx context.Context, req *datatransferpb.DeleteTransferRunRequest, opts ...gax.CallOption) error {
922 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
923
924 hds = append(c.xGoogHeaders, hds...)
925 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
926 opts = append((*c.CallOptions).DeleteTransferRun[0:len((*c.CallOptions).DeleteTransferRun):len((*c.CallOptions).DeleteTransferRun)], opts...)
927 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
928 var err error
929 _, err = c.client.DeleteTransferRun(ctx, req, settings.GRPC...)
930 return err
931 }, opts...)
932 return err
933 }
934
935 func (c *gRPCClient) ListTransferRuns(ctx context.Context, req *datatransferpb.ListTransferRunsRequest, opts ...gax.CallOption) *TransferRunIterator {
936 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
937
938 hds = append(c.xGoogHeaders, hds...)
939 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
940 opts = append((*c.CallOptions).ListTransferRuns[0:len((*c.CallOptions).ListTransferRuns):len((*c.CallOptions).ListTransferRuns)], opts...)
941 it := &TransferRunIterator{}
942 req = proto.Clone(req).(*datatransferpb.ListTransferRunsRequest)
943 it.InternalFetch = func(pageSize int, pageToken string) ([]*datatransferpb.TransferRun, string, error) {
944 resp := &datatransferpb.ListTransferRunsResponse{}
945 if pageToken != "" {
946 req.PageToken = pageToken
947 }
948 if pageSize > math.MaxInt32 {
949 req.PageSize = math.MaxInt32
950 } else if pageSize != 0 {
951 req.PageSize = int32(pageSize)
952 }
953 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
954 var err error
955 resp, err = c.client.ListTransferRuns(ctx, req, settings.GRPC...)
956 return err
957 }, opts...)
958 if err != nil {
959 return nil, "", err
960 }
961
962 it.Response = resp
963 return resp.GetTransferRuns(), resp.GetNextPageToken(), nil
964 }
965 fetch := func(pageSize int, pageToken string) (string, error) {
966 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
967 if err != nil {
968 return "", err
969 }
970 it.items = append(it.items, items...)
971 return nextPageToken, nil
972 }
973
974 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
975 it.pageInfo.MaxSize = int(req.GetPageSize())
976 it.pageInfo.Token = req.GetPageToken()
977
978 return it
979 }
980
981 func (c *gRPCClient) ListTransferLogs(ctx context.Context, req *datatransferpb.ListTransferLogsRequest, opts ...gax.CallOption) *TransferMessageIterator {
982 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
983
984 hds = append(c.xGoogHeaders, hds...)
985 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
986 opts = append((*c.CallOptions).ListTransferLogs[0:len((*c.CallOptions).ListTransferLogs):len((*c.CallOptions).ListTransferLogs)], opts...)
987 it := &TransferMessageIterator{}
988 req = proto.Clone(req).(*datatransferpb.ListTransferLogsRequest)
989 it.InternalFetch = func(pageSize int, pageToken string) ([]*datatransferpb.TransferMessage, string, error) {
990 resp := &datatransferpb.ListTransferLogsResponse{}
991 if pageToken != "" {
992 req.PageToken = pageToken
993 }
994 if pageSize > math.MaxInt32 {
995 req.PageSize = math.MaxInt32
996 } else if pageSize != 0 {
997 req.PageSize = int32(pageSize)
998 }
999 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1000 var err error
1001 resp, err = c.client.ListTransferLogs(ctx, req, settings.GRPC...)
1002 return err
1003 }, opts...)
1004 if err != nil {
1005 return nil, "", err
1006 }
1007
1008 it.Response = resp
1009 return resp.GetTransferMessages(), resp.GetNextPageToken(), nil
1010 }
1011 fetch := func(pageSize int, pageToken string) (string, error) {
1012 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1013 if err != nil {
1014 return "", err
1015 }
1016 it.items = append(it.items, items...)
1017 return nextPageToken, nil
1018 }
1019
1020 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1021 it.pageInfo.MaxSize = int(req.GetPageSize())
1022 it.pageInfo.Token = req.GetPageToken()
1023
1024 return it
1025 }
1026
1027 func (c *gRPCClient) CheckValidCreds(ctx context.Context, req *datatransferpb.CheckValidCredsRequest, opts ...gax.CallOption) (*datatransferpb.CheckValidCredsResponse, error) {
1028 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1029
1030 hds = append(c.xGoogHeaders, hds...)
1031 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1032 opts = append((*c.CallOptions).CheckValidCreds[0:len((*c.CallOptions).CheckValidCreds):len((*c.CallOptions).CheckValidCreds)], opts...)
1033 var resp *datatransferpb.CheckValidCredsResponse
1034 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1035 var err error
1036 resp, err = c.client.CheckValidCreds(ctx, req, settings.GRPC...)
1037 return err
1038 }, opts...)
1039 if err != nil {
1040 return nil, err
1041 }
1042 return resp, nil
1043 }
1044
1045 func (c *gRPCClient) EnrollDataSources(ctx context.Context, req *datatransferpb.EnrollDataSourcesRequest, opts ...gax.CallOption) error {
1046 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1047
1048 hds = append(c.xGoogHeaders, hds...)
1049 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1050 opts = append((*c.CallOptions).EnrollDataSources[0:len((*c.CallOptions).EnrollDataSources):len((*c.CallOptions).EnrollDataSources)], opts...)
1051 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1052 var err error
1053 _, err = c.client.EnrollDataSources(ctx, req, settings.GRPC...)
1054 return err
1055 }, opts...)
1056 return err
1057 }
1058
1059 func (c *gRPCClient) UnenrollDataSources(ctx context.Context, req *datatransferpb.UnenrollDataSourcesRequest, opts ...gax.CallOption) error {
1060 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1061
1062 hds = append(c.xGoogHeaders, hds...)
1063 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1064 opts = append((*c.CallOptions).UnenrollDataSources[0:len((*c.CallOptions).UnenrollDataSources):len((*c.CallOptions).UnenrollDataSources)], opts...)
1065 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1066 var err error
1067 _, err = c.client.UnenrollDataSources(ctx, req, settings.GRPC...)
1068 return err
1069 }, opts...)
1070 return err
1071 }
1072
1073 func (c *gRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
1074 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1075
1076 hds = append(c.xGoogHeaders, hds...)
1077 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1078 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
1079 var resp *locationpb.Location
1080 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1081 var err error
1082 resp, err = c.locationsClient.GetLocation(ctx, req, settings.GRPC...)
1083 return err
1084 }, opts...)
1085 if err != nil {
1086 return nil, err
1087 }
1088 return resp, nil
1089 }
1090
1091 func (c *gRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
1092 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1093
1094 hds = append(c.xGoogHeaders, hds...)
1095 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1096 opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...)
1097 it := &LocationIterator{}
1098 req = proto.Clone(req).(*locationpb.ListLocationsRequest)
1099 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
1100 resp := &locationpb.ListLocationsResponse{}
1101 if pageToken != "" {
1102 req.PageToken = pageToken
1103 }
1104 if pageSize > math.MaxInt32 {
1105 req.PageSize = math.MaxInt32
1106 } else if pageSize != 0 {
1107 req.PageSize = int32(pageSize)
1108 }
1109 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1110 var err error
1111 resp, err = c.locationsClient.ListLocations(ctx, req, settings.GRPC...)
1112 return err
1113 }, opts...)
1114 if err != nil {
1115 return nil, "", err
1116 }
1117
1118 it.Response = resp
1119 return resp.GetLocations(), resp.GetNextPageToken(), nil
1120 }
1121 fetch := func(pageSize int, pageToken string) (string, error) {
1122 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1123 if err != nil {
1124 return "", err
1125 }
1126 it.items = append(it.items, items...)
1127 return nextPageToken, nil
1128 }
1129
1130 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1131 it.pageInfo.MaxSize = int(req.GetPageSize())
1132 it.pageInfo.Token = req.GetPageToken()
1133
1134 return it
1135 }
1136
1137
1138 func (c *restClient) GetDataSource(ctx context.Context, req *datatransferpb.GetDataSourceRequest, opts ...gax.CallOption) (*datatransferpb.DataSource, error) {
1139 baseUrl, err := url.Parse(c.endpoint)
1140 if err != nil {
1141 return nil, err
1142 }
1143 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1144
1145 params := url.Values{}
1146 params.Add("$alt", "json;enum-encoding=int")
1147
1148 baseUrl.RawQuery = params.Encode()
1149
1150
1151 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1152
1153 hds = append(c.xGoogHeaders, hds...)
1154 hds = append(hds, "Content-Type", "application/json")
1155 headers := gax.BuildHeaders(ctx, hds...)
1156 opts = append((*c.CallOptions).GetDataSource[0:len((*c.CallOptions).GetDataSource):len((*c.CallOptions).GetDataSource)], opts...)
1157 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1158 resp := &datatransferpb.DataSource{}
1159 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1160 if settings.Path != "" {
1161 baseUrl.Path = settings.Path
1162 }
1163 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1164 if err != nil {
1165 return err
1166 }
1167 httpReq = httpReq.WithContext(ctx)
1168 httpReq.Header = headers
1169
1170 httpRsp, err := c.httpClient.Do(httpReq)
1171 if err != nil {
1172 return err
1173 }
1174 defer httpRsp.Body.Close()
1175
1176 if err = googleapi.CheckResponse(httpRsp); err != nil {
1177 return err
1178 }
1179
1180 buf, err := io.ReadAll(httpRsp.Body)
1181 if err != nil {
1182 return err
1183 }
1184
1185 if err := unm.Unmarshal(buf, resp); err != nil {
1186 return err
1187 }
1188
1189 return nil
1190 }, opts...)
1191 if e != nil {
1192 return nil, e
1193 }
1194 return resp, nil
1195 }
1196
1197
1198 func (c *restClient) ListDataSources(ctx context.Context, req *datatransferpb.ListDataSourcesRequest, opts ...gax.CallOption) *DataSourceIterator {
1199 it := &DataSourceIterator{}
1200 req = proto.Clone(req).(*datatransferpb.ListDataSourcesRequest)
1201 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1202 it.InternalFetch = func(pageSize int, pageToken string) ([]*datatransferpb.DataSource, string, error) {
1203 resp := &datatransferpb.ListDataSourcesResponse{}
1204 if pageToken != "" {
1205 req.PageToken = pageToken
1206 }
1207 if pageSize > math.MaxInt32 {
1208 req.PageSize = math.MaxInt32
1209 } else if pageSize != 0 {
1210 req.PageSize = int32(pageSize)
1211 }
1212 baseUrl, err := url.Parse(c.endpoint)
1213 if err != nil {
1214 return nil, "", err
1215 }
1216 baseUrl.Path += fmt.Sprintf("/v1/%v/dataSources", req.GetParent())
1217
1218 params := url.Values{}
1219 params.Add("$alt", "json;enum-encoding=int")
1220 if req.GetPageSize() != 0 {
1221 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1222 }
1223 if req.GetPageToken() != "" {
1224 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1225 }
1226
1227 baseUrl.RawQuery = params.Encode()
1228
1229
1230 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1231 headers := gax.BuildHeaders(ctx, hds...)
1232 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1233 if settings.Path != "" {
1234 baseUrl.Path = settings.Path
1235 }
1236 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1237 if err != nil {
1238 return err
1239 }
1240 httpReq.Header = headers
1241
1242 httpRsp, err := c.httpClient.Do(httpReq)
1243 if err != nil {
1244 return err
1245 }
1246 defer httpRsp.Body.Close()
1247
1248 if err = googleapi.CheckResponse(httpRsp); err != nil {
1249 return err
1250 }
1251
1252 buf, err := io.ReadAll(httpRsp.Body)
1253 if err != nil {
1254 return err
1255 }
1256
1257 if err := unm.Unmarshal(buf, resp); err != nil {
1258 return err
1259 }
1260
1261 return nil
1262 }, opts...)
1263 if e != nil {
1264 return nil, "", e
1265 }
1266 it.Response = resp
1267 return resp.GetDataSources(), resp.GetNextPageToken(), nil
1268 }
1269
1270 fetch := func(pageSize int, pageToken string) (string, error) {
1271 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1272 if err != nil {
1273 return "", err
1274 }
1275 it.items = append(it.items, items...)
1276 return nextPageToken, nil
1277 }
1278
1279 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1280 it.pageInfo.MaxSize = int(req.GetPageSize())
1281 it.pageInfo.Token = req.GetPageToken()
1282
1283 return it
1284 }
1285
1286
1287 func (c *restClient) CreateTransferConfig(ctx context.Context, req *datatransferpb.CreateTransferConfigRequest, opts ...gax.CallOption) (*datatransferpb.TransferConfig, error) {
1288 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1289 body := req.GetTransferConfig()
1290 jsonReq, err := m.Marshal(body)
1291 if err != nil {
1292 return nil, err
1293 }
1294
1295 baseUrl, err := url.Parse(c.endpoint)
1296 if err != nil {
1297 return nil, err
1298 }
1299 baseUrl.Path += fmt.Sprintf("/v1/%v/transferConfigs", req.GetParent())
1300
1301 params := url.Values{}
1302 params.Add("$alt", "json;enum-encoding=int")
1303 if req.GetAuthorizationCode() != "" {
1304 params.Add("authorizationCode", fmt.Sprintf("%v", req.GetAuthorizationCode()))
1305 }
1306 if req.GetServiceAccountName() != "" {
1307 params.Add("serviceAccountName", fmt.Sprintf("%v", req.GetServiceAccountName()))
1308 }
1309 if req.GetVersionInfo() != "" {
1310 params.Add("versionInfo", fmt.Sprintf("%v", req.GetVersionInfo()))
1311 }
1312
1313 baseUrl.RawQuery = params.Encode()
1314
1315
1316 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1317
1318 hds = append(c.xGoogHeaders, hds...)
1319 hds = append(hds, "Content-Type", "application/json")
1320 headers := gax.BuildHeaders(ctx, hds...)
1321 opts = append((*c.CallOptions).CreateTransferConfig[0:len((*c.CallOptions).CreateTransferConfig):len((*c.CallOptions).CreateTransferConfig)], opts...)
1322 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1323 resp := &datatransferpb.TransferConfig{}
1324 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1325 if settings.Path != "" {
1326 baseUrl.Path = settings.Path
1327 }
1328 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1329 if err != nil {
1330 return err
1331 }
1332 httpReq = httpReq.WithContext(ctx)
1333 httpReq.Header = headers
1334
1335 httpRsp, err := c.httpClient.Do(httpReq)
1336 if err != nil {
1337 return err
1338 }
1339 defer httpRsp.Body.Close()
1340
1341 if err = googleapi.CheckResponse(httpRsp); err != nil {
1342 return err
1343 }
1344
1345 buf, err := io.ReadAll(httpRsp.Body)
1346 if err != nil {
1347 return err
1348 }
1349
1350 if err := unm.Unmarshal(buf, resp); err != nil {
1351 return err
1352 }
1353
1354 return nil
1355 }, opts...)
1356 if e != nil {
1357 return nil, e
1358 }
1359 return resp, nil
1360 }
1361
1362
1363
1364 func (c *restClient) UpdateTransferConfig(ctx context.Context, req *datatransferpb.UpdateTransferConfigRequest, opts ...gax.CallOption) (*datatransferpb.TransferConfig, error) {
1365 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1366 body := req.GetTransferConfig()
1367 jsonReq, err := m.Marshal(body)
1368 if err != nil {
1369 return nil, err
1370 }
1371
1372 baseUrl, err := url.Parse(c.endpoint)
1373 if err != nil {
1374 return nil, err
1375 }
1376 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetTransferConfig().GetName())
1377
1378 params := url.Values{}
1379 params.Add("$alt", "json;enum-encoding=int")
1380 if req.GetAuthorizationCode() != "" {
1381 params.Add("authorizationCode", fmt.Sprintf("%v", req.GetAuthorizationCode()))
1382 }
1383 if req.GetServiceAccountName() != "" {
1384 params.Add("serviceAccountName", fmt.Sprintf("%v", req.GetServiceAccountName()))
1385 }
1386 if req.GetUpdateMask() != nil {
1387 updateMask, err := protojson.Marshal(req.GetUpdateMask())
1388 if err != nil {
1389 return nil, err
1390 }
1391 params.Add("updateMask", string(updateMask[1:len(updateMask)-1]))
1392 }
1393 if req.GetVersionInfo() != "" {
1394 params.Add("versionInfo", fmt.Sprintf("%v", req.GetVersionInfo()))
1395 }
1396
1397 baseUrl.RawQuery = params.Encode()
1398
1399
1400 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "transfer_config.name", url.QueryEscape(req.GetTransferConfig().GetName()))}
1401
1402 hds = append(c.xGoogHeaders, hds...)
1403 hds = append(hds, "Content-Type", "application/json")
1404 headers := gax.BuildHeaders(ctx, hds...)
1405 opts = append((*c.CallOptions).UpdateTransferConfig[0:len((*c.CallOptions).UpdateTransferConfig):len((*c.CallOptions).UpdateTransferConfig)], opts...)
1406 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1407 resp := &datatransferpb.TransferConfig{}
1408 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1409 if settings.Path != "" {
1410 baseUrl.Path = settings.Path
1411 }
1412 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
1413 if err != nil {
1414 return err
1415 }
1416 httpReq = httpReq.WithContext(ctx)
1417 httpReq.Header = headers
1418
1419 httpRsp, err := c.httpClient.Do(httpReq)
1420 if err != nil {
1421 return err
1422 }
1423 defer httpRsp.Body.Close()
1424
1425 if err = googleapi.CheckResponse(httpRsp); err != nil {
1426 return err
1427 }
1428
1429 buf, err := io.ReadAll(httpRsp.Body)
1430 if err != nil {
1431 return err
1432 }
1433
1434 if err := unm.Unmarshal(buf, resp); err != nil {
1435 return err
1436 }
1437
1438 return nil
1439 }, opts...)
1440 if e != nil {
1441 return nil, e
1442 }
1443 return resp, nil
1444 }
1445
1446
1447
1448 func (c *restClient) DeleteTransferConfig(ctx context.Context, req *datatransferpb.DeleteTransferConfigRequest, opts ...gax.CallOption) error {
1449 baseUrl, err := url.Parse(c.endpoint)
1450 if err != nil {
1451 return err
1452 }
1453 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1454
1455 params := url.Values{}
1456 params.Add("$alt", "json;enum-encoding=int")
1457
1458 baseUrl.RawQuery = params.Encode()
1459
1460
1461 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1462
1463 hds = append(c.xGoogHeaders, hds...)
1464 hds = append(hds, "Content-Type", "application/json")
1465 headers := gax.BuildHeaders(ctx, hds...)
1466 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1467 if settings.Path != "" {
1468 baseUrl.Path = settings.Path
1469 }
1470 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1471 if err != nil {
1472 return err
1473 }
1474 httpReq = httpReq.WithContext(ctx)
1475 httpReq.Header = headers
1476
1477 httpRsp, err := c.httpClient.Do(httpReq)
1478 if err != nil {
1479 return err
1480 }
1481 defer httpRsp.Body.Close()
1482
1483
1484
1485 return googleapi.CheckResponse(httpRsp)
1486 }, opts...)
1487 }
1488
1489
1490 func (c *restClient) GetTransferConfig(ctx context.Context, req *datatransferpb.GetTransferConfigRequest, opts ...gax.CallOption) (*datatransferpb.TransferConfig, error) {
1491 baseUrl, err := url.Parse(c.endpoint)
1492 if err != nil {
1493 return nil, err
1494 }
1495 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1496
1497 params := url.Values{}
1498 params.Add("$alt", "json;enum-encoding=int")
1499
1500 baseUrl.RawQuery = params.Encode()
1501
1502
1503 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1504
1505 hds = append(c.xGoogHeaders, hds...)
1506 hds = append(hds, "Content-Type", "application/json")
1507 headers := gax.BuildHeaders(ctx, hds...)
1508 opts = append((*c.CallOptions).GetTransferConfig[0:len((*c.CallOptions).GetTransferConfig):len((*c.CallOptions).GetTransferConfig)], opts...)
1509 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1510 resp := &datatransferpb.TransferConfig{}
1511 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1512 if settings.Path != "" {
1513 baseUrl.Path = settings.Path
1514 }
1515 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1516 if err != nil {
1517 return err
1518 }
1519 httpReq = httpReq.WithContext(ctx)
1520 httpReq.Header = headers
1521
1522 httpRsp, err := c.httpClient.Do(httpReq)
1523 if err != nil {
1524 return err
1525 }
1526 defer httpRsp.Body.Close()
1527
1528 if err = googleapi.CheckResponse(httpRsp); err != nil {
1529 return err
1530 }
1531
1532 buf, err := io.ReadAll(httpRsp.Body)
1533 if err != nil {
1534 return err
1535 }
1536
1537 if err := unm.Unmarshal(buf, resp); err != nil {
1538 return err
1539 }
1540
1541 return nil
1542 }, opts...)
1543 if e != nil {
1544 return nil, e
1545 }
1546 return resp, nil
1547 }
1548
1549
1550
1551 func (c *restClient) ListTransferConfigs(ctx context.Context, req *datatransferpb.ListTransferConfigsRequest, opts ...gax.CallOption) *TransferConfigIterator {
1552 it := &TransferConfigIterator{}
1553 req = proto.Clone(req).(*datatransferpb.ListTransferConfigsRequest)
1554 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1555 it.InternalFetch = func(pageSize int, pageToken string) ([]*datatransferpb.TransferConfig, string, error) {
1556 resp := &datatransferpb.ListTransferConfigsResponse{}
1557 if pageToken != "" {
1558 req.PageToken = pageToken
1559 }
1560 if pageSize > math.MaxInt32 {
1561 req.PageSize = math.MaxInt32
1562 } else if pageSize != 0 {
1563 req.PageSize = int32(pageSize)
1564 }
1565 baseUrl, err := url.Parse(c.endpoint)
1566 if err != nil {
1567 return nil, "", err
1568 }
1569 baseUrl.Path += fmt.Sprintf("/v1/%v/transferConfigs", req.GetParent())
1570
1571 params := url.Values{}
1572 params.Add("$alt", "json;enum-encoding=int")
1573 if items := req.GetDataSourceIds(); len(items) > 0 {
1574 for _, item := range items {
1575 params.Add("dataSourceIds", fmt.Sprintf("%v", item))
1576 }
1577 }
1578 if req.GetPageSize() != 0 {
1579 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1580 }
1581 if req.GetPageToken() != "" {
1582 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1583 }
1584
1585 baseUrl.RawQuery = params.Encode()
1586
1587
1588 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1589 headers := gax.BuildHeaders(ctx, hds...)
1590 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1591 if settings.Path != "" {
1592 baseUrl.Path = settings.Path
1593 }
1594 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1595 if err != nil {
1596 return err
1597 }
1598 httpReq.Header = headers
1599
1600 httpRsp, err := c.httpClient.Do(httpReq)
1601 if err != nil {
1602 return err
1603 }
1604 defer httpRsp.Body.Close()
1605
1606 if err = googleapi.CheckResponse(httpRsp); err != nil {
1607 return err
1608 }
1609
1610 buf, err := io.ReadAll(httpRsp.Body)
1611 if err != nil {
1612 return err
1613 }
1614
1615 if err := unm.Unmarshal(buf, resp); err != nil {
1616 return err
1617 }
1618
1619 return nil
1620 }, opts...)
1621 if e != nil {
1622 return nil, "", e
1623 }
1624 it.Response = resp
1625 return resp.GetTransferConfigs(), resp.GetNextPageToken(), nil
1626 }
1627
1628 fetch := func(pageSize int, pageToken string) (string, error) {
1629 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1630 if err != nil {
1631 return "", err
1632 }
1633 it.items = append(it.items, items...)
1634 return nextPageToken, nil
1635 }
1636
1637 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1638 it.pageInfo.MaxSize = int(req.GetPageSize())
1639 it.pageInfo.Token = req.GetPageToken()
1640
1641 return it
1642 }
1643
1644
1645
1646
1647
1648
1649
1650
1651 func (c *restClient) ScheduleTransferRuns(ctx context.Context, req *datatransferpb.ScheduleTransferRunsRequest, opts ...gax.CallOption) (*datatransferpb.ScheduleTransferRunsResponse, error) {
1652 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1653 jsonReq, err := m.Marshal(req)
1654 if err != nil {
1655 return nil, err
1656 }
1657
1658 baseUrl, err := url.Parse(c.endpoint)
1659 if err != nil {
1660 return nil, err
1661 }
1662 baseUrl.Path += fmt.Sprintf("/v1/%v:scheduleRuns", req.GetParent())
1663
1664 params := url.Values{}
1665 params.Add("$alt", "json;enum-encoding=int")
1666
1667 baseUrl.RawQuery = params.Encode()
1668
1669
1670 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1671
1672 hds = append(c.xGoogHeaders, hds...)
1673 hds = append(hds, "Content-Type", "application/json")
1674 headers := gax.BuildHeaders(ctx, hds...)
1675 opts = append((*c.CallOptions).ScheduleTransferRuns[0:len((*c.CallOptions).ScheduleTransferRuns):len((*c.CallOptions).ScheduleTransferRuns)], opts...)
1676 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1677 resp := &datatransferpb.ScheduleTransferRunsResponse{}
1678 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1679 if settings.Path != "" {
1680 baseUrl.Path = settings.Path
1681 }
1682 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1683 if err != nil {
1684 return err
1685 }
1686 httpReq = httpReq.WithContext(ctx)
1687 httpReq.Header = headers
1688
1689 httpRsp, err := c.httpClient.Do(httpReq)
1690 if err != nil {
1691 return err
1692 }
1693 defer httpRsp.Body.Close()
1694
1695 if err = googleapi.CheckResponse(httpRsp); err != nil {
1696 return err
1697 }
1698
1699 buf, err := io.ReadAll(httpRsp.Body)
1700 if err != nil {
1701 return err
1702 }
1703
1704 if err := unm.Unmarshal(buf, resp); err != nil {
1705 return err
1706 }
1707
1708 return nil
1709 }, opts...)
1710 if e != nil {
1711 return nil, e
1712 }
1713 return resp, nil
1714 }
1715
1716
1717
1718
1719
1720 func (c *restClient) StartManualTransferRuns(ctx context.Context, req *datatransferpb.StartManualTransferRunsRequest, opts ...gax.CallOption) (*datatransferpb.StartManualTransferRunsResponse, error) {
1721 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1722 jsonReq, err := m.Marshal(req)
1723 if err != nil {
1724 return nil, err
1725 }
1726
1727 baseUrl, err := url.Parse(c.endpoint)
1728 if err != nil {
1729 return nil, err
1730 }
1731 baseUrl.Path += fmt.Sprintf("/v1/%v:startManualRuns", req.GetParent())
1732
1733 params := url.Values{}
1734 params.Add("$alt", "json;enum-encoding=int")
1735
1736 baseUrl.RawQuery = params.Encode()
1737
1738
1739 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1740
1741 hds = append(c.xGoogHeaders, hds...)
1742 hds = append(hds, "Content-Type", "application/json")
1743 headers := gax.BuildHeaders(ctx, hds...)
1744 opts = append((*c.CallOptions).StartManualTransferRuns[0:len((*c.CallOptions).StartManualTransferRuns):len((*c.CallOptions).StartManualTransferRuns)], opts...)
1745 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1746 resp := &datatransferpb.StartManualTransferRunsResponse{}
1747 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1748 if settings.Path != "" {
1749 baseUrl.Path = settings.Path
1750 }
1751 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1752 if err != nil {
1753 return err
1754 }
1755 httpReq = httpReq.WithContext(ctx)
1756 httpReq.Header = headers
1757
1758 httpRsp, err := c.httpClient.Do(httpReq)
1759 if err != nil {
1760 return err
1761 }
1762 defer httpRsp.Body.Close()
1763
1764 if err = googleapi.CheckResponse(httpRsp); err != nil {
1765 return err
1766 }
1767
1768 buf, err := io.ReadAll(httpRsp.Body)
1769 if err != nil {
1770 return err
1771 }
1772
1773 if err := unm.Unmarshal(buf, resp); err != nil {
1774 return err
1775 }
1776
1777 return nil
1778 }, opts...)
1779 if e != nil {
1780 return nil, e
1781 }
1782 return resp, nil
1783 }
1784
1785
1786 func (c *restClient) GetTransferRun(ctx context.Context, req *datatransferpb.GetTransferRunRequest, opts ...gax.CallOption) (*datatransferpb.TransferRun, error) {
1787 baseUrl, err := url.Parse(c.endpoint)
1788 if err != nil {
1789 return nil, err
1790 }
1791 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1792
1793 params := url.Values{}
1794 params.Add("$alt", "json;enum-encoding=int")
1795
1796 baseUrl.RawQuery = params.Encode()
1797
1798
1799 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1800
1801 hds = append(c.xGoogHeaders, hds...)
1802 hds = append(hds, "Content-Type", "application/json")
1803 headers := gax.BuildHeaders(ctx, hds...)
1804 opts = append((*c.CallOptions).GetTransferRun[0:len((*c.CallOptions).GetTransferRun):len((*c.CallOptions).GetTransferRun)], opts...)
1805 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1806 resp := &datatransferpb.TransferRun{}
1807 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1808 if settings.Path != "" {
1809 baseUrl.Path = settings.Path
1810 }
1811 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1812 if err != nil {
1813 return err
1814 }
1815 httpReq = httpReq.WithContext(ctx)
1816 httpReq.Header = headers
1817
1818 httpRsp, err := c.httpClient.Do(httpReq)
1819 if err != nil {
1820 return err
1821 }
1822 defer httpRsp.Body.Close()
1823
1824 if err = googleapi.CheckResponse(httpRsp); err != nil {
1825 return err
1826 }
1827
1828 buf, err := io.ReadAll(httpRsp.Body)
1829 if err != nil {
1830 return err
1831 }
1832
1833 if err := unm.Unmarshal(buf, resp); err != nil {
1834 return err
1835 }
1836
1837 return nil
1838 }, opts...)
1839 if e != nil {
1840 return nil, e
1841 }
1842 return resp, nil
1843 }
1844
1845
1846 func (c *restClient) DeleteTransferRun(ctx context.Context, req *datatransferpb.DeleteTransferRunRequest, opts ...gax.CallOption) error {
1847 baseUrl, err := url.Parse(c.endpoint)
1848 if err != nil {
1849 return err
1850 }
1851 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1852
1853 params := url.Values{}
1854 params.Add("$alt", "json;enum-encoding=int")
1855
1856 baseUrl.RawQuery = params.Encode()
1857
1858
1859 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1860
1861 hds = append(c.xGoogHeaders, hds...)
1862 hds = append(hds, "Content-Type", "application/json")
1863 headers := gax.BuildHeaders(ctx, hds...)
1864 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1865 if settings.Path != "" {
1866 baseUrl.Path = settings.Path
1867 }
1868 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1869 if err != nil {
1870 return err
1871 }
1872 httpReq = httpReq.WithContext(ctx)
1873 httpReq.Header = headers
1874
1875 httpRsp, err := c.httpClient.Do(httpReq)
1876 if err != nil {
1877 return err
1878 }
1879 defer httpRsp.Body.Close()
1880
1881
1882
1883 return googleapi.CheckResponse(httpRsp)
1884 }, opts...)
1885 }
1886
1887
1888 func (c *restClient) ListTransferRuns(ctx context.Context, req *datatransferpb.ListTransferRunsRequest, opts ...gax.CallOption) *TransferRunIterator {
1889 it := &TransferRunIterator{}
1890 req = proto.Clone(req).(*datatransferpb.ListTransferRunsRequest)
1891 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1892 it.InternalFetch = func(pageSize int, pageToken string) ([]*datatransferpb.TransferRun, string, error) {
1893 resp := &datatransferpb.ListTransferRunsResponse{}
1894 if pageToken != "" {
1895 req.PageToken = pageToken
1896 }
1897 if pageSize > math.MaxInt32 {
1898 req.PageSize = math.MaxInt32
1899 } else if pageSize != 0 {
1900 req.PageSize = int32(pageSize)
1901 }
1902 baseUrl, err := url.Parse(c.endpoint)
1903 if err != nil {
1904 return nil, "", err
1905 }
1906 baseUrl.Path += fmt.Sprintf("/v1/%v/runs", req.GetParent())
1907
1908 params := url.Values{}
1909 params.Add("$alt", "json;enum-encoding=int")
1910 if req.GetPageSize() != 0 {
1911 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1912 }
1913 if req.GetPageToken() != "" {
1914 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1915 }
1916 if req.GetRunAttempt() != 0 {
1917 params.Add("runAttempt", fmt.Sprintf("%v", req.GetRunAttempt()))
1918 }
1919 if items := req.GetStates(); len(items) > 0 {
1920 for _, item := range items {
1921 params.Add("states", fmt.Sprintf("%v", item))
1922 }
1923 }
1924
1925 baseUrl.RawQuery = params.Encode()
1926
1927
1928 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1929 headers := gax.BuildHeaders(ctx, hds...)
1930 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1931 if settings.Path != "" {
1932 baseUrl.Path = settings.Path
1933 }
1934 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1935 if err != nil {
1936 return err
1937 }
1938 httpReq.Header = headers
1939
1940 httpRsp, err := c.httpClient.Do(httpReq)
1941 if err != nil {
1942 return err
1943 }
1944 defer httpRsp.Body.Close()
1945
1946 if err = googleapi.CheckResponse(httpRsp); err != nil {
1947 return err
1948 }
1949
1950 buf, err := io.ReadAll(httpRsp.Body)
1951 if err != nil {
1952 return err
1953 }
1954
1955 if err := unm.Unmarshal(buf, resp); err != nil {
1956 return err
1957 }
1958
1959 return nil
1960 }, opts...)
1961 if e != nil {
1962 return nil, "", e
1963 }
1964 it.Response = resp
1965 return resp.GetTransferRuns(), resp.GetNextPageToken(), nil
1966 }
1967
1968 fetch := func(pageSize int, pageToken string) (string, error) {
1969 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1970 if err != nil {
1971 return "", err
1972 }
1973 it.items = append(it.items, items...)
1974 return nextPageToken, nil
1975 }
1976
1977 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1978 it.pageInfo.MaxSize = int(req.GetPageSize())
1979 it.pageInfo.Token = req.GetPageToken()
1980
1981 return it
1982 }
1983
1984
1985 func (c *restClient) ListTransferLogs(ctx context.Context, req *datatransferpb.ListTransferLogsRequest, opts ...gax.CallOption) *TransferMessageIterator {
1986 it := &TransferMessageIterator{}
1987 req = proto.Clone(req).(*datatransferpb.ListTransferLogsRequest)
1988 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1989 it.InternalFetch = func(pageSize int, pageToken string) ([]*datatransferpb.TransferMessage, string, error) {
1990 resp := &datatransferpb.ListTransferLogsResponse{}
1991 if pageToken != "" {
1992 req.PageToken = pageToken
1993 }
1994 if pageSize > math.MaxInt32 {
1995 req.PageSize = math.MaxInt32
1996 } else if pageSize != 0 {
1997 req.PageSize = int32(pageSize)
1998 }
1999 baseUrl, err := url.Parse(c.endpoint)
2000 if err != nil {
2001 return nil, "", err
2002 }
2003 baseUrl.Path += fmt.Sprintf("/v1/%v/transferLogs", req.GetParent())
2004
2005 params := url.Values{}
2006 params.Add("$alt", "json;enum-encoding=int")
2007 if items := req.GetMessageTypes(); len(items) > 0 {
2008 for _, item := range items {
2009 params.Add("messageTypes", fmt.Sprintf("%v", item))
2010 }
2011 }
2012 if req.GetPageSize() != 0 {
2013 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2014 }
2015 if req.GetPageToken() != "" {
2016 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2017 }
2018
2019 baseUrl.RawQuery = params.Encode()
2020
2021
2022 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2023 headers := gax.BuildHeaders(ctx, hds...)
2024 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2025 if settings.Path != "" {
2026 baseUrl.Path = settings.Path
2027 }
2028 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2029 if err != nil {
2030 return err
2031 }
2032 httpReq.Header = headers
2033
2034 httpRsp, err := c.httpClient.Do(httpReq)
2035 if err != nil {
2036 return err
2037 }
2038 defer httpRsp.Body.Close()
2039
2040 if err = googleapi.CheckResponse(httpRsp); err != nil {
2041 return err
2042 }
2043
2044 buf, err := io.ReadAll(httpRsp.Body)
2045 if err != nil {
2046 return err
2047 }
2048
2049 if err := unm.Unmarshal(buf, resp); err != nil {
2050 return err
2051 }
2052
2053 return nil
2054 }, opts...)
2055 if e != nil {
2056 return nil, "", e
2057 }
2058 it.Response = resp
2059 return resp.GetTransferMessages(), resp.GetNextPageToken(), nil
2060 }
2061
2062 fetch := func(pageSize int, pageToken string) (string, error) {
2063 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2064 if err != nil {
2065 return "", err
2066 }
2067 it.items = append(it.items, items...)
2068 return nextPageToken, nil
2069 }
2070
2071 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2072 it.pageInfo.MaxSize = int(req.GetPageSize())
2073 it.pageInfo.Token = req.GetPageToken()
2074
2075 return it
2076 }
2077
2078
2079
2080 func (c *restClient) CheckValidCreds(ctx context.Context, req *datatransferpb.CheckValidCredsRequest, opts ...gax.CallOption) (*datatransferpb.CheckValidCredsResponse, error) {
2081 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2082 jsonReq, err := m.Marshal(req)
2083 if err != nil {
2084 return nil, err
2085 }
2086
2087 baseUrl, err := url.Parse(c.endpoint)
2088 if err != nil {
2089 return nil, err
2090 }
2091 baseUrl.Path += fmt.Sprintf("/v1/%v:checkValidCreds", req.GetName())
2092
2093 params := url.Values{}
2094 params.Add("$alt", "json;enum-encoding=int")
2095
2096 baseUrl.RawQuery = params.Encode()
2097
2098
2099 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2100
2101 hds = append(c.xGoogHeaders, hds...)
2102 hds = append(hds, "Content-Type", "application/json")
2103 headers := gax.BuildHeaders(ctx, hds...)
2104 opts = append((*c.CallOptions).CheckValidCreds[0:len((*c.CallOptions).CheckValidCreds):len((*c.CallOptions).CheckValidCreds)], opts...)
2105 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2106 resp := &datatransferpb.CheckValidCredsResponse{}
2107 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2108 if settings.Path != "" {
2109 baseUrl.Path = settings.Path
2110 }
2111 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2112 if err != nil {
2113 return err
2114 }
2115 httpReq = httpReq.WithContext(ctx)
2116 httpReq.Header = headers
2117
2118 httpRsp, err := c.httpClient.Do(httpReq)
2119 if err != nil {
2120 return err
2121 }
2122 defer httpRsp.Body.Close()
2123
2124 if err = googleapi.CheckResponse(httpRsp); err != nil {
2125 return err
2126 }
2127
2128 buf, err := io.ReadAll(httpRsp.Body)
2129 if err != nil {
2130 return err
2131 }
2132
2133 if err := unm.Unmarshal(buf, resp); err != nil {
2134 return err
2135 }
2136
2137 return nil
2138 }, opts...)
2139 if e != nil {
2140 return nil, e
2141 }
2142 return resp, nil
2143 }
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153 func (c *restClient) EnrollDataSources(ctx context.Context, req *datatransferpb.EnrollDataSourcesRequest, opts ...gax.CallOption) error {
2154 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2155 jsonReq, err := m.Marshal(req)
2156 if err != nil {
2157 return err
2158 }
2159
2160 baseUrl, err := url.Parse(c.endpoint)
2161 if err != nil {
2162 return err
2163 }
2164 baseUrl.Path += fmt.Sprintf("/v1/%v:enrollDataSources", req.GetName())
2165
2166 params := url.Values{}
2167 params.Add("$alt", "json;enum-encoding=int")
2168
2169 baseUrl.RawQuery = params.Encode()
2170
2171
2172 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2173
2174 hds = append(c.xGoogHeaders, hds...)
2175 hds = append(hds, "Content-Type", "application/json")
2176 headers := gax.BuildHeaders(ctx, hds...)
2177 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2178 if settings.Path != "" {
2179 baseUrl.Path = settings.Path
2180 }
2181 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2182 if err != nil {
2183 return err
2184 }
2185 httpReq = httpReq.WithContext(ctx)
2186 httpReq.Header = headers
2187
2188 httpRsp, err := c.httpClient.Do(httpReq)
2189 if err != nil {
2190 return err
2191 }
2192 defer httpRsp.Body.Close()
2193
2194
2195
2196 return googleapi.CheckResponse(httpRsp)
2197 }, opts...)
2198 }
2199
2200
2201
2202
2203
2204
2205 func (c *restClient) UnenrollDataSources(ctx context.Context, req *datatransferpb.UnenrollDataSourcesRequest, opts ...gax.CallOption) error {
2206 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2207 jsonReq, err := m.Marshal(req)
2208 if err != nil {
2209 return err
2210 }
2211
2212 baseUrl, err := url.Parse(c.endpoint)
2213 if err != nil {
2214 return err
2215 }
2216 baseUrl.Path += fmt.Sprintf("/v1/%v:unenrollDataSources", req.GetName())
2217
2218 params := url.Values{}
2219 params.Add("$alt", "json;enum-encoding=int")
2220
2221 baseUrl.RawQuery = params.Encode()
2222
2223
2224 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2225
2226 hds = append(c.xGoogHeaders, hds...)
2227 hds = append(hds, "Content-Type", "application/json")
2228 headers := gax.BuildHeaders(ctx, hds...)
2229 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2230 if settings.Path != "" {
2231 baseUrl.Path = settings.Path
2232 }
2233 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2234 if err != nil {
2235 return err
2236 }
2237 httpReq = httpReq.WithContext(ctx)
2238 httpReq.Header = headers
2239
2240 httpRsp, err := c.httpClient.Do(httpReq)
2241 if err != nil {
2242 return err
2243 }
2244 defer httpRsp.Body.Close()
2245
2246
2247
2248 return googleapi.CheckResponse(httpRsp)
2249 }, opts...)
2250 }
2251
2252
2253 func (c *restClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
2254 baseUrl, err := url.Parse(c.endpoint)
2255 if err != nil {
2256 return nil, err
2257 }
2258 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2259
2260 params := url.Values{}
2261 params.Add("$alt", "json;enum-encoding=int")
2262
2263 baseUrl.RawQuery = params.Encode()
2264
2265
2266 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2267
2268 hds = append(c.xGoogHeaders, hds...)
2269 hds = append(hds, "Content-Type", "application/json")
2270 headers := gax.BuildHeaders(ctx, hds...)
2271 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
2272 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2273 resp := &locationpb.Location{}
2274 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2275 if settings.Path != "" {
2276 baseUrl.Path = settings.Path
2277 }
2278 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2279 if err != nil {
2280 return err
2281 }
2282 httpReq = httpReq.WithContext(ctx)
2283 httpReq.Header = headers
2284
2285 httpRsp, err := c.httpClient.Do(httpReq)
2286 if err != nil {
2287 return err
2288 }
2289 defer httpRsp.Body.Close()
2290
2291 if err = googleapi.CheckResponse(httpRsp); err != nil {
2292 return err
2293 }
2294
2295 buf, err := io.ReadAll(httpRsp.Body)
2296 if err != nil {
2297 return err
2298 }
2299
2300 if err := unm.Unmarshal(buf, resp); err != nil {
2301 return err
2302 }
2303
2304 return nil
2305 }, opts...)
2306 if e != nil {
2307 return nil, e
2308 }
2309 return resp, nil
2310 }
2311
2312
2313 func (c *restClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
2314 it := &LocationIterator{}
2315 req = proto.Clone(req).(*locationpb.ListLocationsRequest)
2316 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2317 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
2318 resp := &locationpb.ListLocationsResponse{}
2319 if pageToken != "" {
2320 req.PageToken = pageToken
2321 }
2322 if pageSize > math.MaxInt32 {
2323 req.PageSize = math.MaxInt32
2324 } else if pageSize != 0 {
2325 req.PageSize = int32(pageSize)
2326 }
2327 baseUrl, err := url.Parse(c.endpoint)
2328 if err != nil {
2329 return nil, "", err
2330 }
2331 baseUrl.Path += fmt.Sprintf("/v1/%v/locations", req.GetName())
2332
2333 params := url.Values{}
2334 params.Add("$alt", "json;enum-encoding=int")
2335 if req.GetFilter() != "" {
2336 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
2337 }
2338 if req.GetPageSize() != 0 {
2339 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2340 }
2341 if req.GetPageToken() != "" {
2342 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2343 }
2344
2345 baseUrl.RawQuery = params.Encode()
2346
2347
2348 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2349 headers := gax.BuildHeaders(ctx, hds...)
2350 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2351 if settings.Path != "" {
2352 baseUrl.Path = settings.Path
2353 }
2354 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2355 if err != nil {
2356 return err
2357 }
2358 httpReq.Header = headers
2359
2360 httpRsp, err := c.httpClient.Do(httpReq)
2361 if err != nil {
2362 return err
2363 }
2364 defer httpRsp.Body.Close()
2365
2366 if err = googleapi.CheckResponse(httpRsp); err != nil {
2367 return err
2368 }
2369
2370 buf, err := io.ReadAll(httpRsp.Body)
2371 if err != nil {
2372 return err
2373 }
2374
2375 if err := unm.Unmarshal(buf, resp); err != nil {
2376 return err
2377 }
2378
2379 return nil
2380 }, opts...)
2381 if e != nil {
2382 return nil, "", e
2383 }
2384 it.Response = resp
2385 return resp.GetLocations(), resp.GetNextPageToken(), nil
2386 }
2387
2388 fetch := func(pageSize int, pageToken string) (string, error) {
2389 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2390 if err != nil {
2391 return "", err
2392 }
2393 it.items = append(it.items, items...)
2394 return nextPageToken, nil
2395 }
2396
2397 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2398 it.pageInfo.MaxSize = int(req.GetPageSize())
2399 it.pageInfo.Token = req.GetPageToken()
2400
2401 return it
2402 }
2403
View as plain text