Class: Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/bigquery/data_transfer/v1/data_transfer_service_client.rb

Overview

The Google BigQuery Data Transfer Service API enables BigQuery users to configure the transfer of their data from other Google Products into BigQuery. This service contains methods that are end user exposed. It backs up the frontend.

Constant Summary collapse

SERVICE_ADDRESS =

The default address of the service.

"bigquerydatatransfer.googleapis.com".freeze
DEFAULT_SERVICE_PORT =

The default port of the service.

443
DEFAULT_TIMEOUT =
30
ALL_SCOPES =

The scopes needed to make gRPC calls to all of the methods defined in this service.

[
  "https://www.googleapis.com/auth/cloud-platform"
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(credentials: nil, scopes: ALL_SCOPES, client_config: {}, timeout: DEFAULT_TIMEOUT, lib_name: nil, lib_version: "") ⇒ DataTransferServiceClient

Returns a new instance of DataTransferServiceClient

Parameters:

  • credentials (Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc)

    Provides the means for authenticating requests made by the client. This parameter can be many types. A Google::Auth::Credentials uses a the properties of its represented keyfile for authenticating requests made by this client. A String will be treated as the path to the keyfile to be used for the construction of credentials for this client. A Hash will be treated as the contents of a keyfile to be used for the construction of credentials for this client. A GRPC::Core::Channel will be used to make calls through. A GRPC::Core::ChannelCredentials for the setting up the RPC client. The channel credentials should already be composed with a GRPC::Core::CallCredentials object. A Proc will be used as an updater_proc for the Grpc channel. The proc transforms the metadata for requests, generally, to give OAuth credentials.

  • scopes (Array<String>)

    The OAuth scopes for this service. This parameter is ignored if an updater_proc is supplied.

  • client_config (Hash)

    A Hash for call options for each method. See Google::Gax#construct_settings for the structure of this data. Falls back to the default config if not specified or the specified config is missing data points.

  • timeout (Numeric)

    The default timeout, in seconds, for calls made through this client.



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/google/cloud/bigquery/data_transfer/v1/data_transfer_service_client.rb', line 173

def initialize \
    credentials: nil,
    scopes: ALL_SCOPES,
    client_config: {},
    timeout: DEFAULT_TIMEOUT,
    lib_name: nil,
    lib_version: ""
  # These require statements are intentionally placed here to initialize
  # the gRPC module only when it's required.
  # See https://github.com/googleapis/toolkit/issues/446
  require "google/gax/grpc"
  require "google/cloud/bigquery/data_transfer/v1/data_transfer_services_pb"

  credentials ||= Google::Cloud::Bigquery::DataTransfer::Credentials.default

  if credentials.is_a?(String) || credentials.is_a?(Hash)
    updater_proc = Google::Cloud::Bigquery::DataTransfer::Credentials.new(credentials).updater_proc
  end
  if credentials.is_a?(GRPC::Core::Channel)
    channel = credentials
  end
  if credentials.is_a?(GRPC::Core::ChannelCredentials)
    chan_creds = credentials
  end
  if credentials.is_a?(Proc)
    updater_proc = credentials
  end
  if credentials.is_a?(Google::Auth::Credentials)
    updater_proc = credentials.updater_proc
  end

  package_version = Gem.loaded_specs['google-cloud-bigquery-data_transfer'].version.version

  google_api_client = "gl-ruby/#{RUBY_VERSION}"
  google_api_client << " #{lib_name}/#{lib_version}" if lib_name
  google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
  google_api_client << " grpc/#{GRPC::VERSION}"
  google_api_client.freeze

  headers = { :"x-goog-api-client" => google_api_client }
  client_config_file = Pathname.new(__dir__).join(
    "data_transfer_service_client_config.json"
  )
  defaults = client_config_file.open do |f|
    Google::Gax.construct_settings(
      "google.cloud.bigquery.datatransfer.v1.DataTransferService",
      JSON.parse(f.read),
      client_config,
      Google::Gax::Grpc::STATUS_CODE_NAMES,
      timeout,
      page_descriptors: PAGE_DESCRIPTORS,
      errors: Google::Gax::Grpc::API_ERRORS,
      kwargs: headers
    )
  end

  # Allow overriding the service path/port in subclasses.
  service_path = self.class::SERVICE_ADDRESS
  port = self.class::DEFAULT_SERVICE_PORT
  @data_transfer_service_stub = Google::Gax::Grpc.create_stub(
    service_path,
    port,
    chan_creds: chan_creds,
    channel: channel,
    updater_proc: updater_proc,
    scopes: scopes,
    &Google::Cloud::Bigquery::DataTransfer::V1::DataTransferService::Stub.method(:new)
  )

  @get_data_source = Google::Gax.create_api_call(
    @data_transfer_service_stub.method(:get_data_source),
    defaults["get_data_source"]
  )
  @list_data_sources = Google::Gax.create_api_call(
    @data_transfer_service_stub.method(:list_data_sources),
    defaults["list_data_sources"]
  )
  @create_transfer_config = Google::Gax.create_api_call(
    @data_transfer_service_stub.method(:create_transfer_config),
    defaults["create_transfer_config"]
  )
  @update_transfer_config = Google::Gax.create_api_call(
    @data_transfer_service_stub.method(:update_transfer_config),
    defaults["update_transfer_config"]
  )
  @delete_transfer_config = Google::Gax.create_api_call(
    @data_transfer_service_stub.method(:delete_transfer_config),
    defaults["delete_transfer_config"]
  )
  @get_transfer_config = Google::Gax.create_api_call(
    @data_transfer_service_stub.method(:get_transfer_config),
    defaults["get_transfer_config"]
  )
  @list_transfer_configs = Google::Gax.create_api_call(
    @data_transfer_service_stub.method(:list_transfer_configs),
    defaults["list_transfer_configs"]
  )
  @schedule_transfer_runs = Google::Gax.create_api_call(
    @data_transfer_service_stub.method(:schedule_transfer_runs),
    defaults["schedule_transfer_runs"]
  )
  @get_transfer_run = Google::Gax.create_api_call(
    @data_transfer_service_stub.method(:get_transfer_run),
    defaults["get_transfer_run"]
  )
  @delete_transfer_run = Google::Gax.create_api_call(
    @data_transfer_service_stub.method(:delete_transfer_run),
    defaults["delete_transfer_run"]
  )
  @list_transfer_runs = Google::Gax.create_api_call(
    @data_transfer_service_stub.method(:list_transfer_runs),
    defaults["list_transfer_runs"]
  )
  @list_transfer_logs = Google::Gax.create_api_call(
    @data_transfer_service_stub.method(:list_transfer_logs),
    defaults["list_transfer_logs"]
  )
  @check_valid_creds = Google::Gax.create_api_call(
    @data_transfer_service_stub.method(:check_valid_creds),
    defaults["check_valid_creds"]
  )
end

Instance Attribute Details

#data_transfer_service_stubGoogle::Cloud::Bigquery::DataTransfer::V1::DataTransferService::Stub (readonly)

Returns:

  • (Google::Cloud::Bigquery::DataTransfer::V1::DataTransferService::Stub)


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
# File 'lib/google/cloud/bigquery/data_transfer/v1/data_transfer_service_client.rb', line 42

class DataTransferServiceClient
  attr_reader :data_transfer_service_stub

  # The default address of the service.
  SERVICE_ADDRESS = "bigquerydatatransfer.googleapis.com".freeze

  # The default port of the service.
  DEFAULT_SERVICE_PORT = 443

  DEFAULT_TIMEOUT = 30

  PAGE_DESCRIPTORS = {
    "list_data_sources" => Google::Gax::PageDescriptor.new(
      "page_token",
      "next_page_token",
      "data_sources"),
    "list_transfer_configs" => Google::Gax::PageDescriptor.new(
      "page_token",
      "next_page_token",
      "transfer_configs"),
    "list_transfer_runs" => Google::Gax::PageDescriptor.new(
      "page_token",
      "next_page_token",
      "transfer_runs"),
    "list_transfer_logs" => Google::Gax::PageDescriptor.new(
      "page_token",
      "next_page_token",
      "transfer_messages")
  }.freeze

  private_constant :PAGE_DESCRIPTORS

  # The scopes needed to make gRPC calls to all of the methods defined in
  # this service.
  ALL_SCOPES = [
    "https://www.googleapis.com/auth/cloud-platform"
  ].freeze


  PROJECT_DATA_SOURCE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
    "projects/{project}/dataSources/{data_source}"
  )

  private_constant :PROJECT_DATA_SOURCE_PATH_TEMPLATE

  PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
    "projects/{project}"
  )

  private_constant :PROJECT_PATH_TEMPLATE

  PROJECT_TRANSFER_CONFIG_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
    "projects/{project}/transferConfigs/{transfer_config}"
  )

  private_constant :PROJECT_TRANSFER_CONFIG_PATH_TEMPLATE

  PROJECT_RUN_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
    "projects/{project}/transferConfigs/{transfer_config}/runs/{run}"
  )

  private_constant :PROJECT_RUN_PATH_TEMPLATE

  # Returns a fully-qualified project_data_source resource name string.
  # @param project [String]
  # @param data_source [String]
  # @return [String]
  def self.project_data_source_path project, data_source
    PROJECT_DATA_SOURCE_PATH_TEMPLATE.render(
      :"project" => project,
      :"data_source" => data_source
    )
  end

  # Returns a fully-qualified project resource name string.
  # @param project [String]
  # @return [String]
  def self.project_path project
    PROJECT_PATH_TEMPLATE.render(
      :"project" => project
    )
  end

  # Returns a fully-qualified project_transfer_config resource name string.
  # @param project [String]
  # @param transfer_config [String]
  # @return [String]
  def self.project_transfer_config_path project, transfer_config
    PROJECT_TRANSFER_CONFIG_PATH_TEMPLATE.render(
      :"project" => project,
      :"transfer_config" => transfer_config
    )
  end

  # Returns a fully-qualified project_run resource name string.
  # @param project [String]
  # @param transfer_config [String]
  # @param run [String]
  # @return [String]
  def self.project_run_path project, transfer_config, run
    PROJECT_RUN_PATH_TEMPLATE.render(
      :"project" => project,
      :"transfer_config" => transfer_config,
      :"run" => run
    )
  end

  # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
  #   Provides the means for authenticating requests made by the client. This parameter can
  #   be many types.
  #   A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
  #   authenticating requests made by this client.
  #   A `String` will be treated as the path to the keyfile to be used for the construction of
  #   credentials for this client.
  #   A `Hash` will be treated as the contents of a keyfile to be used for the construction of
  #   credentials for this client.
  #   A `GRPC::Core::Channel` will be used to make calls through.
  #   A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
  #   should already be composed with a `GRPC::Core::CallCredentials` object.
  #   A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
  #   metadata for requests, generally, to give OAuth credentials.
  # @param scopes [Array<String>]
  #   The OAuth scopes for this service. This parameter is ignored if
  #   an updater_proc is supplied.
  # @param client_config [Hash]
  #   A Hash for call options for each method. See
  #   Google::Gax#construct_settings for the structure of
  #   this data. Falls back to the default config if not specified
  #   or the specified config is missing data points.
  # @param timeout [Numeric]
  #   The default timeout, in seconds, for calls made through this client.
  def initialize \
      credentials: nil,
      scopes: ALL_SCOPES,
      client_config: {},
      timeout: DEFAULT_TIMEOUT,
      lib_name: nil,
      lib_version: ""
    # These require statements are intentionally placed here to initialize
    # the gRPC module only when it's required.
    # See https://github.com/googleapis/toolkit/issues/446
    require "google/gax/grpc"
    require "google/cloud/bigquery/data_transfer/v1/data_transfer_services_pb"

    credentials ||= Google::Cloud::Bigquery::DataTransfer::Credentials.default

    if credentials.is_a?(String) || credentials.is_a?(Hash)
      updater_proc = Google::Cloud::Bigquery::DataTransfer::Credentials.new(credentials).updater_proc
    end
    if credentials.is_a?(GRPC::Core::Channel)
      channel = credentials
    end
    if credentials.is_a?(GRPC::Core::ChannelCredentials)
      chan_creds = credentials
    end
    if credentials.is_a?(Proc)
      updater_proc = credentials
    end
    if credentials.is_a?(Google::Auth::Credentials)
      updater_proc = credentials.updater_proc
    end

    package_version = Gem.loaded_specs['google-cloud-bigquery-data_transfer'].version.version

    google_api_client = "gl-ruby/#{RUBY_VERSION}"
    google_api_client << " #{lib_name}/#{lib_version}" if lib_name
    google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
    google_api_client << " grpc/#{GRPC::VERSION}"
    google_api_client.freeze

    headers = { :"x-goog-api-client" => google_api_client }
    client_config_file = Pathname.new(__dir__).join(
      "data_transfer_service_client_config.json"
    )
    defaults = client_config_file.open do |f|
      Google::Gax.construct_settings(
        "google.cloud.bigquery.datatransfer.v1.DataTransferService",
        JSON.parse(f.read),
        client_config,
        Google::Gax::Grpc::STATUS_CODE_NAMES,
        timeout,
        page_descriptors: PAGE_DESCRIPTORS,
        errors: Google::Gax::Grpc::API_ERRORS,
        kwargs: headers
      )
    end

    # Allow overriding the service path/port in subclasses.
    service_path = self.class::SERVICE_ADDRESS
    port = self.class::DEFAULT_SERVICE_PORT
    @data_transfer_service_stub = Google::Gax::Grpc.create_stub(
      service_path,
      port,
      chan_creds: chan_creds,
      channel: channel,
      updater_proc: updater_proc,
      scopes: scopes,
      &Google::Cloud::Bigquery::DataTransfer::V1::DataTransferService::Stub.method(:new)
    )

    @get_data_source = Google::Gax.create_api_call(
      @data_transfer_service_stub.method(:get_data_source),
      defaults["get_data_source"]
    )
    @list_data_sources = Google::Gax.create_api_call(
      @data_transfer_service_stub.method(:list_data_sources),
      defaults["list_data_sources"]
    )
    @create_transfer_config = Google::Gax.create_api_call(
      @data_transfer_service_stub.method(:create_transfer_config),
      defaults["create_transfer_config"]
    )
    @update_transfer_config = Google::Gax.create_api_call(
      @data_transfer_service_stub.method(:update_transfer_config),
      defaults["update_transfer_config"]
    )
    @delete_transfer_config = Google::Gax.create_api_call(
      @data_transfer_service_stub.method(:delete_transfer_config),
      defaults["delete_transfer_config"]
    )
    @get_transfer_config = Google::Gax.create_api_call(
      @data_transfer_service_stub.method(:get_transfer_config),
      defaults["get_transfer_config"]
    )
    @list_transfer_configs = Google::Gax.create_api_call(
      @data_transfer_service_stub.method(:list_transfer_configs),
      defaults["list_transfer_configs"]
    )
    @schedule_transfer_runs = Google::Gax.create_api_call(
      @data_transfer_service_stub.method(:schedule_transfer_runs),
      defaults["schedule_transfer_runs"]
    )
    @get_transfer_run = Google::Gax.create_api_call(
      @data_transfer_service_stub.method(:get_transfer_run),
      defaults["get_transfer_run"]
    )
    @delete_transfer_run = Google::Gax.create_api_call(
      @data_transfer_service_stub.method(:delete_transfer_run),
      defaults["delete_transfer_run"]
    )
    @list_transfer_runs = Google::Gax.create_api_call(
      @data_transfer_service_stub.method(:list_transfer_runs),
      defaults["list_transfer_runs"]
    )
    @list_transfer_logs = Google::Gax.create_api_call(
      @data_transfer_service_stub.method(:list_transfer_logs),
      defaults["list_transfer_logs"]
    )
    @check_valid_creds = Google::Gax.create_api_call(
      @data_transfer_service_stub.method(:check_valid_creds),
      defaults["check_valid_creds"]
    )
  end

  # Service calls

  # Retrieves a supported data source and returns its settings,
  # which can be used for UI rendering.
  #
  # @param name [String]
  #   The field will contain name of the resource requested, for example:
  #   +projects/{project_id}/dataSources/{data_source_id}+
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @return [Google::Cloud::Bigquery::DataTransfer::V1::DataSource]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/bigquery/data_transfer/v1"
  #
  #   data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
  #   formatted_name = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient.project_data_source_path("[PROJECT]", "[DATA_SOURCE]")
  #   response = data_transfer_service_client.get_data_source(formatted_name)

  def get_data_source \
      name,
      options: nil
    req = {
      name: name
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::GetDataSourceRequest)
    @get_data_source.call(req, options)
  end

  # Lists supported data sources and returns their settings,
  # which can be used for UI rendering.
  #
  # @param parent [String]
  #   The BigQuery project id for which data sources should be returned.
  #   Must be in the form: +projects/{project_id}+
  # @param page_size [Integer]
  #   The maximum number of resources contained in the underlying API
  #   response. If page streaming is performed per-resource, this
  #   parameter does not affect the return value. If page streaming is
  #   performed per-page, this determines the maximum number of
  #   resources in a page.
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @return [Google::Gax::PagedEnumerable<Google::Cloud::Bigquery::DataTransfer::V1::DataSource>]
  #   An enumerable of Google::Cloud::Bigquery::DataTransfer::V1::DataSource instances.
  #   See Google::Gax::PagedEnumerable documentation for other
  #   operations such as per-page iteration or access to the response
  #   object.
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/bigquery/data_transfer/v1"
  #
  #   data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
  #   formatted_parent = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient.project_path("[PROJECT]")
  #
  #   # Iterate over all results.
  #   data_transfer_service_client.list_data_sources(formatted_parent).each do |element|
  #     # Process element.
  #   end
  #
  #   # Or iterate over results one page at a time.
  #   data_transfer_service_client.list_data_sources(formatted_parent).each_page do |page|
  #     # Process each page at a time.
  #     page.each do |element|
  #       # Process element.
  #     end
  #   end

  def list_data_sources \
      parent,
      page_size: nil,
      options: nil
    req = {
      parent: parent,
      page_size: page_size
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::ListDataSourcesRequest)
    @list_data_sources.call(req, options)
  end

  # Creates a new data transfer configuration.
  #
  # @param parent [String]
  #   The BigQuery project id where the transfer configuration should be created.
  #   Must be in the format /projects/{project_id}/locations/{location_id}
  #   If specified location and location of the destination bigquery dataset
  #   do not match - the request will fail.
  # @param transfer_config [Google::Cloud::Bigquery::DataTransfer::V1::TransferConfig | Hash]
  #   Data transfer configuration to create.
  #   A hash of the same form as `Google::Cloud::Bigquery::DataTransfer::V1::TransferConfig`
  #   can also be provided.
  # @param authorization_code [String]
  #   Optional OAuth2 authorization code to use with this transfer configuration.
  #   This is required if new credentials are needed, as indicated by
  #   +CheckValidCreds+.
  #   In order to obtain authorization_code, please make a
  #   request to
  #   https://www.gstatic.com/bigquerydatatransfer/oauthz/auth?client_id=<datatransferapiclientid>&scope=<data_source_scopes>&redirect_uri=<redirect_uri>
  #
  #   * client_id should be OAuth client_id of BigQuery DTS API for the given
  #     data source returned by ListDataSources method.
  #   * data_source_scopes are the scopes returned by ListDataSources method.
  #   * redirect_uri is an optional parameter. If not specified, then
  #     authorization code is posted to the opener of authorization flow window.
  #     Otherwise it will be sent to the redirect uri. A special value of
  #     urn:ietf:wg:oauth:2.0:oob means that authorization code should be
  #     returned in the title bar of the browser, with the page text prompting
  #     the user to copy the code and paste it in the application.
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @return [Google::Cloud::Bigquery::DataTransfer::V1::TransferConfig]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/bigquery/data_transfer/v1"
  #
  #   data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
  #   formatted_parent = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient.project_path("[PROJECT]")
  #
  #   # TODO: Initialize +transfer_config+:
  #   transfer_config = {}
  #   response = data_transfer_service_client.create_transfer_config(formatted_parent, transfer_config)

  def create_transfer_config \
      parent,
      transfer_config,
      authorization_code: nil,
      options: nil
    req = {
      parent: parent,
      transfer_config: transfer_config,
      authorization_code: authorization_code
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::CreateTransferConfigRequest)
    @create_transfer_config.call(req, options)
  end

  # Updates a data transfer configuration.
  # All fields must be set, even if they are not updated.
  #
  # @param transfer_config [Google::Cloud::Bigquery::DataTransfer::V1::TransferConfig | Hash]
  #   Data transfer configuration to create.
  #   A hash of the same form as `Google::Cloud::Bigquery::DataTransfer::V1::TransferConfig`
  #   can also be provided.
  # @param update_mask [Google::Protobuf::FieldMask | Hash]
  #   Required list of fields to be updated in this request.
  #   A hash of the same form as `Google::Protobuf::FieldMask`
  #   can also be provided.
  # @param authorization_code [String]
  #   Optional OAuth2 authorization code to use with this transfer configuration.
  #   If it is provided, the transfer configuration will be associated with the
  #   authorizing user.
  #   In order to obtain authorization_code, please make a
  #   request to
  #   https://www.gstatic.com/bigquerydatatransfer/oauthz/auth?client_id=<datatransferapiclientid>&scope=<data_source_scopes>&redirect_uri=<redirect_uri>
  #
  #   * client_id should be OAuth client_id of BigQuery DTS API for the given
  #     data source returned by ListDataSources method.
  #   * data_source_scopes are the scopes returned by ListDataSources method.
  #   * redirect_uri is an optional parameter. If not specified, then
  #     authorization code is posted to the opener of authorization flow window.
  #     Otherwise it will be sent to the redirect uri. A special value of
  #     urn:ietf:wg:oauth:2.0:oob means that authorization code should be
  #     returned in the title bar of the browser, with the page text prompting
  #     the user to copy the code and paste it in the application.
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @return [Google::Cloud::Bigquery::DataTransfer::V1::TransferConfig]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/bigquery/data_transfer/v1"
  #
  #   data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
  #
  #   # TODO: Initialize +transfer_config+:
  #   transfer_config = {}
  #
  #   # TODO: Initialize +update_mask+:
  #   update_mask = {}
  #   response = data_transfer_service_client.update_transfer_config(transfer_config, update_mask)

  def update_transfer_config \
      transfer_config,
      update_mask,
      authorization_code: nil,
      options: nil
    req = {
      transfer_config: transfer_config,
      update_mask: update_mask,
      authorization_code: authorization_code
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::UpdateTransferConfigRequest)
    @update_transfer_config.call(req, options)
  end

  # Deletes a data transfer configuration,
  # including any associated transfer runs and logs.
  #
  # @param name [String]
  #   The field will contain name of the resource requested, for example:
  #   +projects/{project_id}/transferConfigs/{config_id}+
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/bigquery/data_transfer/v1"
  #
  #   data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
  #   formatted_name = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient.project_transfer_config_path("[PROJECT]", "[TRANSFER_CONFIG]")
  #   data_transfer_service_client.delete_transfer_config(formatted_name)

  def delete_transfer_config \
      name,
      options: nil
    req = {
      name: name
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::DeleteTransferConfigRequest)
    @delete_transfer_config.call(req, options)
    nil
  end

  # Returns information about a data transfer config.
  #
  # @param name [String]
  #   The field will contain name of the resource requested, for example:
  #   +projects/{project_id}/transferConfigs/{config_id}+
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @return [Google::Cloud::Bigquery::DataTransfer::V1::TransferConfig]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/bigquery/data_transfer/v1"
  #
  #   data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
  #   formatted_name = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient.project_transfer_config_path("[PROJECT]", "[TRANSFER_CONFIG]")
  #   response = data_transfer_service_client.get_transfer_config(formatted_name)

  def get_transfer_config \
      name,
      options: nil
    req = {
      name: name
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::GetTransferConfigRequest)
    @get_transfer_config.call(req, options)
  end

  # Returns information about all data transfers in the project.
  #
  # @param parent [String]
  #   The BigQuery project id for which data sources
  #   should be returned: +projects/{project_id}+.
  # @param data_source_ids [Array<String>]
  #   When specified, only configurations of requested data sources are returned.
  # @param page_size [Integer]
  #   The maximum number of resources contained in the underlying API
  #   response. If page streaming is performed per-resource, this
  #   parameter does not affect the return value. If page streaming is
  #   performed per-page, this determines the maximum number of
  #   resources in a page.
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @return [Google::Gax::PagedEnumerable<Google::Cloud::Bigquery::DataTransfer::V1::TransferConfig>]
  #   An enumerable of Google::Cloud::Bigquery::DataTransfer::V1::TransferConfig instances.
  #   See Google::Gax::PagedEnumerable documentation for other
  #   operations such as per-page iteration or access to the response
  #   object.
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/bigquery/data_transfer/v1"
  #
  #   data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
  #   formatted_parent = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient.project_path("[PROJECT]")
  #
  #   # Iterate over all results.
  #   data_transfer_service_client.list_transfer_configs(formatted_parent).each do |element|
  #     # Process element.
  #   end
  #
  #   # Or iterate over results one page at a time.
  #   data_transfer_service_client.list_transfer_configs(formatted_parent).each_page do |page|
  #     # Process each page at a time.
  #     page.each do |element|
  #       # Process element.
  #     end
  #   end

  def list_transfer_configs \
      parent,
      data_source_ids: nil,
      page_size: nil,
      options: nil
    req = {
      parent: parent,
      data_source_ids: data_source_ids,
      page_size: page_size
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::ListTransferConfigsRequest)
    @list_transfer_configs.call(req, options)
  end

  # Creates transfer runs for a time range [start_time, end_time].
  # For each date - or whatever granularity the data source supports - in the
  # range, one transfer run is created.
  # Note that runs are created per UTC time in the time range.
  #
  # @param parent [String]
  #   Transfer configuration name in the form:
  #   +projects/{project_id}/transferConfigs/{config_id}+.
  # @param start_time [Google::Protobuf::Timestamp | Hash]
  #   Start time of the range of transfer runs. For example,
  #   +"2017-05-25T00:00:00+00:00"+.
  #   A hash of the same form as `Google::Protobuf::Timestamp`
  #   can also be provided.
  # @param end_time [Google::Protobuf::Timestamp | Hash]
  #   End time of the range of transfer runs. For example,
  #   +"2017-05-30T00:00:00+00:00"+.
  #   A hash of the same form as `Google::Protobuf::Timestamp`
  #   can also be provided.
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @return [Google::Cloud::Bigquery::DataTransfer::V1::ScheduleTransferRunsResponse]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/bigquery/data_transfer/v1"
  #
  #   data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
  #   formatted_parent = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient.project_transfer_config_path("[PROJECT]", "[TRANSFER_CONFIG]")
  #
  #   # TODO: Initialize +start_time+:
  #   start_time = {}
  #
  #   # TODO: Initialize +end_time+:
  #   end_time = {}
  #   response = data_transfer_service_client.schedule_transfer_runs(formatted_parent, start_time, end_time)

  def schedule_transfer_runs \
      parent,
      start_time,
      end_time,
      options: nil
    req = {
      parent: parent,
      start_time: start_time,
      end_time: end_time
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::ScheduleTransferRunsRequest)
    @schedule_transfer_runs.call(req, options)
  end

  # Returns information about the particular transfer run.
  #
  # @param name [String]
  #   The field will contain name of the resource requested, for example:
  #   +projects/{project_id}/transferConfigs/{config_id}/runs/{run_id}+
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @return [Google::Cloud::Bigquery::DataTransfer::V1::TransferRun]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/bigquery/data_transfer/v1"
  #
  #   data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
  #   formatted_name = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient.project_run_path("[PROJECT]", "[TRANSFER_CONFIG]", "[RUN]")
  #   response = data_transfer_service_client.get_transfer_run(formatted_name)

  def get_transfer_run \
      name,
      options: nil
    req = {
      name: name
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::GetTransferRunRequest)
    @get_transfer_run.call(req, options)
  end

  # Deletes the specified transfer run.
  #
  # @param name [String]
  #   The field will contain name of the resource requested, for example:
  #   +projects/{project_id}/transferConfigs/{config_id}/runs/{run_id}+
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/bigquery/data_transfer/v1"
  #
  #   data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
  #   formatted_name = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient.project_run_path("[PROJECT]", "[TRANSFER_CONFIG]", "[RUN]")
  #   data_transfer_service_client.delete_transfer_run(formatted_name)

  def delete_transfer_run \
      name,
      options: nil
    req = {
      name: name
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::DeleteTransferRunRequest)
    @delete_transfer_run.call(req, options)
    nil
  end

  # Returns information about running and completed jobs.
  #
  # @param parent [String]
  #   Name of transfer configuration for which transfer runs should be retrieved.
  #   Format of transfer configuration resource name is:
  #   +projects/{project_id}/transferConfigs/{config_id}+.
  # @param states [Array<Google::Cloud::Bigquery::DataTransfer::V1::TransferState>]
  #   When specified, only transfer runs with requested states are returned.
  # @param page_size [Integer]
  #   The maximum number of resources contained in the underlying API
  #   response. If page streaming is performed per-resource, this
  #   parameter does not affect the return value. If page streaming is
  #   performed per-page, this determines the maximum number of
  #   resources in a page.
  # @param run_attempt [Google::Cloud::Bigquery::DataTransfer::V1::ListTransferRunsRequest::RunAttempt]
  #   Indicates how run attempts are to be pulled.
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @return [Google::Gax::PagedEnumerable<Google::Cloud::Bigquery::DataTransfer::V1::TransferRun>]
  #   An enumerable of Google::Cloud::Bigquery::DataTransfer::V1::TransferRun instances.
  #   See Google::Gax::PagedEnumerable documentation for other
  #   operations such as per-page iteration or access to the response
  #   object.
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/bigquery/data_transfer/v1"
  #
  #   data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
  #   formatted_parent = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient.project_transfer_config_path("[PROJECT]", "[TRANSFER_CONFIG]")
  #
  #   # Iterate over all results.
  #   data_transfer_service_client.list_transfer_runs(formatted_parent).each do |element|
  #     # Process element.
  #   end
  #
  #   # Or iterate over results one page at a time.
  #   data_transfer_service_client.list_transfer_runs(formatted_parent).each_page do |page|
  #     # Process each page at a time.
  #     page.each do |element|
  #       # Process element.
  #     end
  #   end

  def list_transfer_runs \
      parent,
      states: nil,
      page_size: nil,
      run_attempt: nil,
      options: nil
    req = {
      parent: parent,
      states: states,
      page_size: page_size,
      run_attempt: run_attempt
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::ListTransferRunsRequest)
    @list_transfer_runs.call(req, options)
  end

  # Returns user facing log messages for the data transfer run.
  #
  # @param parent [String]
  #   Transfer run name in the form:
  #   +projects/{project_id}/transferConfigs/{config_Id}/runs/{run_id}+.
  # @param page_size [Integer]
  #   The maximum number of resources contained in the underlying API
  #   response. If page streaming is performed per-resource, this
  #   parameter does not affect the return value. If page streaming is
  #   performed per-page, this determines the maximum number of
  #   resources in a page.
  # @param message_types [Array<Google::Cloud::Bigquery::DataTransfer::V1::TransferMessage::MessageSeverity>]
  #   Message types to return. If not populated - INFO, WARNING and ERROR
  #   messages are returned.
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @return [Google::Gax::PagedEnumerable<Google::Cloud::Bigquery::DataTransfer::V1::TransferMessage>]
  #   An enumerable of Google::Cloud::Bigquery::DataTransfer::V1::TransferMessage instances.
  #   See Google::Gax::PagedEnumerable documentation for other
  #   operations such as per-page iteration or access to the response
  #   object.
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/bigquery/data_transfer/v1"
  #
  #   data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
  #   formatted_parent = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient.project_run_path("[PROJECT]", "[TRANSFER_CONFIG]", "[RUN]")
  #
  #   # Iterate over all results.
  #   data_transfer_service_client.list_transfer_logs(formatted_parent).each do |element|
  #     # Process element.
  #   end
  #
  #   # Or iterate over results one page at a time.
  #   data_transfer_service_client.list_transfer_logs(formatted_parent).each_page do |page|
  #     # Process each page at a time.
  #     page.each do |element|
  #       # Process element.
  #     end
  #   end

  def list_transfer_logs \
      parent,
      page_size: nil,
      message_types: nil,
      options: nil
    req = {
      parent: parent,
      page_size: page_size,
      message_types: message_types
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::ListTransferLogsRequest)
    @list_transfer_logs.call(req, options)
  end

  # Returns true if valid credentials exist for the given data source and
  # requesting user.
  # Some data sources doesn't support service account, so we need to talk to
  # them on behalf of the end user. This API just checks whether we have OAuth
  # token for the particular user, which is a pre-requisite before user can
  # create a transfer config.
  #
  # @param name [String]
  #   The data source in the form:
  #   +projects/{project_id}/dataSources/{data_source_id}+
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @return [Google::Cloud::Bigquery::DataTransfer::V1::CheckValidCredsResponse]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/bigquery/data_transfer/v1"
  #
  #   data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
  #   formatted_name = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient.project_data_source_path("[PROJECT]", "[DATA_SOURCE]")
  #   response = data_transfer_service_client.check_valid_creds(formatted_name)

  def check_valid_creds \
      name,
      options: nil
    req = {
      name: name
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::CheckValidCredsRequest)
    @check_valid_creds.call(req, options)
  end
end

Class Method Details

.project_data_source_path(project, data_source) ⇒ String

Returns a fully-qualified project_data_source resource name string.

Parameters:

  • project (String)
  • data_source (String)

Returns:

  • (String)


109
110
111
112
113
114
# File 'lib/google/cloud/bigquery/data_transfer/v1/data_transfer_service_client.rb', line 109

def self.project_data_source_path project, data_source
  PROJECT_DATA_SOURCE_PATH_TEMPLATE.render(
    :"project" => project,
    :"data_source" => data_source
  )
end

.project_path(project) ⇒ String

Returns a fully-qualified project resource name string.

Parameters:

  • project (String)

Returns:

  • (String)


119
120
121
122
123
# File 'lib/google/cloud/bigquery/data_transfer/v1/data_transfer_service_client.rb', line 119

def self.project_path project
  PROJECT_PATH_TEMPLATE.render(
    :"project" => project
  )
end

.project_run_path(project, transfer_config, run) ⇒ String

Returns a fully-qualified project_run resource name string.

Parameters:

  • project (String)
  • transfer_config (String)
  • run (String)

Returns:

  • (String)


141
142
143
144
145
146
147
# File 'lib/google/cloud/bigquery/data_transfer/v1/data_transfer_service_client.rb', line 141

def self.project_run_path project, transfer_config, run
  PROJECT_RUN_PATH_TEMPLATE.render(
    :"project" => project,
    :"transfer_config" => transfer_config,
    :"run" => run
  )
end

.project_transfer_config_path(project, transfer_config) ⇒ String

Returns a fully-qualified project_transfer_config resource name string.

Parameters:

  • project (String)
  • transfer_config (String)

Returns:

  • (String)


129
130
131
132
133
134
# File 'lib/google/cloud/bigquery/data_transfer/v1/data_transfer_service_client.rb', line 129

def self.project_transfer_config_path project, transfer_config
  PROJECT_TRANSFER_CONFIG_PATH_TEMPLATE.render(
    :"project" => project,
    :"transfer_config" => transfer_config
  )
end

Instance Method Details

#check_valid_creds(name, options: nil) ⇒ Google::Cloud::Bigquery::DataTransfer::V1::CheckValidCredsResponse

Returns true if valid credentials exist for the given data source and requesting user. Some data sources doesn't support service account, so we need to talk to them on behalf of the end user. This API just checks whether we have OAuth token for the particular user, which is a pre-requisite before user can create a transfer config.

Examples:

require "google/cloud/bigquery/data_transfer/v1"

data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
formatted_name = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient.project_data_source_path("[PROJECT]", "[DATA_SOURCE]")
response = data_transfer_service_client.check_valid_creds(formatted_name)

Parameters:

  • name (String)

    The data source in the form: +projects/project_id/dataSources/data_source_id+

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



846
847
848
849
850
851
852
853
854
# File 'lib/google/cloud/bigquery/data_transfer/v1/data_transfer_service_client.rb', line 846

def check_valid_creds \
    name,
    options: nil
  req = {
    name: name
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::CheckValidCredsRequest)
  @check_valid_creds.call(req, options)
end

#create_transfer_config(parent, transfer_config, authorization_code: nil, options: nil) ⇒ Google::Cloud::Bigquery::DataTransfer::V1::TransferConfig

Creates a new data transfer configuration.

Examples:

require "google/cloud/bigquery/data_transfer/v1"

data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
formatted_parent = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient.project_path("[PROJECT]")

# TODO: Initialize +transfer_config+:
transfer_config = {}
response = data_transfer_service_client.create_transfer_config(formatted_parent, transfer_config)

Parameters:

  • parent (String)

    The BigQuery project id where the transfer configuration should be created. Must be in the format /projects/project_id/locations/location_id If specified location and location of the destination bigquery dataset do not match - the request will fail.

  • transfer_config (Google::Cloud::Bigquery::DataTransfer::V1::TransferConfig | Hash)

    Data transfer configuration to create. A hash of the same form as Google::Cloud::Bigquery::DataTransfer::V1::TransferConfig can also be provided.

  • authorization_code (String)

    Optional OAuth2 authorization code to use with this transfer configuration. This is required if new credentials are needed, as indicated by +CheckValidCreds+. In order to obtain authorization_code, please make a request to https://www.gstatic.com/bigquerydatatransfer/oauthz/auth?client_id=&scope=&redirect_uri=

    • client_id should be OAuth client_id of BigQuery DTS API for the given data source returned by ListDataSources method.
    • data_source_scopes are the scopes returned by ListDataSources method.
    • redirect_uri is an optional parameter. If not specified, then authorization code is posted to the opener of authorization flow window. Otherwise it will be sent to the redirect uri. A special value of urn:ietf:wg:oauth:2.0:oob means that authorization code should be returned in the title bar of the browser, with the page text prompting the user to copy the code and paste it in the application.
  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



421
422
423
424
425
426
427
428
429
430
431
432
433
# File 'lib/google/cloud/bigquery/data_transfer/v1/data_transfer_service_client.rb', line 421

def create_transfer_config \
    parent,
    transfer_config,
    authorization_code: nil,
    options: nil
  req = {
    parent: parent,
    transfer_config: transfer_config,
    authorization_code: authorization_code
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::CreateTransferConfigRequest)
  @create_transfer_config.call(req, options)
end

#delete_transfer_config(name, options: nil) ⇒ Object

Deletes a data transfer configuration, including any associated transfer runs and logs.

Examples:

require "google/cloud/bigquery/data_transfer/v1"

data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
formatted_name = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient.project_transfer_config_path("[PROJECT]", "[TRANSFER_CONFIG]")
data_transfer_service_client.delete_transfer_config(formatted_name)

Parameters:

  • name (String)

    The field will contain name of the resource requested, for example: +projects/project_id/transferConfigs/config_id+

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



511
512
513
514
515
516
517
518
519
520
# File 'lib/google/cloud/bigquery/data_transfer/v1/data_transfer_service_client.rb', line 511

def delete_transfer_config \
    name,
    options: nil
  req = {
    name: name
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::DeleteTransferConfigRequest)
  @delete_transfer_config.call(req, options)
  nil
end

#delete_transfer_run(name, options: nil) ⇒ Object

Deletes the specified transfer run.

Examples:

require "google/cloud/bigquery/data_transfer/v1"

data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
formatted_name = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient.project_run_path("[PROJECT]", "[TRANSFER_CONFIG]", "[RUN]")
data_transfer_service_client.delete_transfer_run(formatted_name)

Parameters:

  • name (String)

    The field will contain name of the resource requested, for example: +projects/project_id/transferConfigs/config_id/runs/run_id+

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



697
698
699
700
701
702
703
704
705
706
# File 'lib/google/cloud/bigquery/data_transfer/v1/data_transfer_service_client.rb', line 697

def delete_transfer_run \
    name,
    options: nil
  req = {
    name: name
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::DeleteTransferRunRequest)
  @delete_transfer_run.call(req, options)
  nil
end

#get_data_source(name, options: nil) ⇒ Google::Cloud::Bigquery::DataTransfer::V1::DataSource

Retrieves a supported data source and returns its settings, which can be used for UI rendering.

Examples:

require "google/cloud/bigquery/data_transfer/v1"

data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
formatted_name = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient.project_data_source_path("[PROJECT]", "[DATA_SOURCE]")
response = data_transfer_service_client.get_data_source(formatted_name)

Parameters:

  • name (String)

    The field will contain name of the resource requested, for example: +projects/project_id/dataSources/data_source_id+

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



316
317
318
319
320
321
322
323
324
# File 'lib/google/cloud/bigquery/data_transfer/v1/data_transfer_service_client.rb', line 316

def get_data_source \
    name,
    options: nil
  req = {
    name: name
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::GetDataSourceRequest)
  @get_data_source.call(req, options)
end

#get_transfer_config(name, options: nil) ⇒ Google::Cloud::Bigquery::DataTransfer::V1::TransferConfig

Returns information about a data transfer config.

Examples:

require "google/cloud/bigquery/data_transfer/v1"

data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
formatted_name = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient.project_transfer_config_path("[PROJECT]", "[TRANSFER_CONFIG]")
response = data_transfer_service_client.get_transfer_config(formatted_name)

Parameters:

  • name (String)

    The field will contain name of the resource requested, for example: +projects/project_id/transferConfigs/config_id+

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



539
540
541
542
543
544
545
546
547
# File 'lib/google/cloud/bigquery/data_transfer/v1/data_transfer_service_client.rb', line 539

def get_transfer_config \
    name,
    options: nil
  req = {
    name: name
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::GetTransferConfigRequest)
  @get_transfer_config.call(req, options)
end

#get_transfer_run(name, options: nil) ⇒ Google::Cloud::Bigquery::DataTransfer::V1::TransferRun

Returns information about the particular transfer run.

Examples:

require "google/cloud/bigquery/data_transfer/v1"

data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
formatted_name = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient.project_run_path("[PROJECT]", "[TRANSFER_CONFIG]", "[RUN]")
response = data_transfer_service_client.get_transfer_run(formatted_name)

Parameters:

  • name (String)

    The field will contain name of the resource requested, for example: +projects/project_id/transferConfigs/config_id/runs/run_id+

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



671
672
673
674
675
676
677
678
679
# File 'lib/google/cloud/bigquery/data_transfer/v1/data_transfer_service_client.rb', line 671

def get_transfer_run \
    name,
    options: nil
  req = {
    name: name
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::GetTransferRunRequest)
  @get_transfer_run.call(req, options)
end

#list_data_sources(parent, page_size: nil, options: nil) ⇒ Google::Gax::PagedEnumerable<Google::Cloud::Bigquery::DataTransfer::V1::DataSource>

Lists supported data sources and returns their settings, which can be used for UI rendering.

Examples:

require "google/cloud/bigquery/data_transfer/v1"

data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
formatted_parent = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient.project_path("[PROJECT]")

# Iterate over all results.
data_transfer_service_client.list_data_sources(formatted_parent).each do |element|
  # Process element.
end

# Or iterate over results one page at a time.
data_transfer_service_client.list_data_sources(formatted_parent).each_page do |page|
  # Process each page at a time.
  page.each do |element|
    # Process element.
  end
end

Parameters:

  • parent (String)

    The BigQuery project id for which data sources should be returned. Must be in the form: +projects/project_id+

  • page_size (Integer)

    The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Returns:

  • (Google::Gax::PagedEnumerable<Google::Cloud::Bigquery::DataTransfer::V1::DataSource>)

    An enumerable of Google::Cloud::Bigquery::DataTransfer::V1::DataSource instances. See Google::Gax::PagedEnumerable documentation for other operations such as per-page iteration or access to the response object.

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



366
367
368
369
370
371
372
373
374
375
376
# File 'lib/google/cloud/bigquery/data_transfer/v1/data_transfer_service_client.rb', line 366

def list_data_sources \
    parent,
    page_size: nil,
    options: nil
  req = {
    parent: parent,
    page_size: page_size
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::ListDataSourcesRequest)
  @list_data_sources.call(req, options)
end

#list_transfer_configs(parent, data_source_ids: nil, page_size: nil, options: nil) ⇒ Google::Gax::PagedEnumerable<Google::Cloud::Bigquery::DataTransfer::V1::TransferConfig>

Returns information about all data transfers in the project.

Examples:

require "google/cloud/bigquery/data_transfer/v1"

data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
formatted_parent = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient.project_path("[PROJECT]")

# Iterate over all results.
data_transfer_service_client.list_transfer_configs(formatted_parent).each do |element|
  # Process element.
end

# Or iterate over results one page at a time.
data_transfer_service_client.list_transfer_configs(formatted_parent).each_page do |page|
  # Process each page at a time.
  page.each do |element|
    # Process element.
  end
end

Parameters:

  • parent (String)

    The BigQuery project id for which data sources should be returned: +projects/project_id+.

  • data_source_ids (Array<String>)

    When specified, only configurations of requested data sources are returned.

  • page_size (Integer)

    The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Returns:

  • (Google::Gax::PagedEnumerable<Google::Cloud::Bigquery::DataTransfer::V1::TransferConfig>)

    An enumerable of Google::Cloud::Bigquery::DataTransfer::V1::TransferConfig instances. See Google::Gax::PagedEnumerable documentation for other operations such as per-page iteration or access to the response object.

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



590
591
592
593
594
595
596
597
598
599
600
601
602
# File 'lib/google/cloud/bigquery/data_transfer/v1/data_transfer_service_client.rb', line 590

def list_transfer_configs \
    parent,
    data_source_ids: nil,
    page_size: nil,
    options: nil
  req = {
    parent: parent,
    data_source_ids: data_source_ids,
    page_size: page_size
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::ListTransferConfigsRequest)
  @list_transfer_configs.call(req, options)
end

#list_transfer_logs(parent, page_size: nil, message_types: nil, options: nil) ⇒ Google::Gax::PagedEnumerable<Google::Cloud::Bigquery::DataTransfer::V1::TransferMessage>

Returns user facing log messages for the data transfer run.

Examples:

require "google/cloud/bigquery/data_transfer/v1"

data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
formatted_parent = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient.project_run_path("[PROJECT]", "[TRANSFER_CONFIG]", "[RUN]")

# Iterate over all results.
data_transfer_service_client.list_transfer_logs(formatted_parent).each do |element|
  # Process element.
end

# Or iterate over results one page at a time.
data_transfer_service_client.list_transfer_logs(formatted_parent).each_page do |page|
  # Process each page at a time.
  page.each do |element|
    # Process element.
  end
end

Parameters:

  • parent (String)

    Transfer run name in the form: +projects/project_id/transferConfigs/config_Id/runs/run_id+.

  • page_size (Integer)

    The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

  • message_types (Array<Google::Cloud::Bigquery::DataTransfer::V1::TransferMessage::MessageSeverity>)

    Message types to return. If not populated - INFO, WARNING and ERROR messages are returned.

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Returns:

  • (Google::Gax::PagedEnumerable<Google::Cloud::Bigquery::DataTransfer::V1::TransferMessage>)

    An enumerable of Google::Cloud::Bigquery::DataTransfer::V1::TransferMessage instances. See Google::Gax::PagedEnumerable documentation for other operations such as per-page iteration or access to the response object.

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



810
811
812
813
814
815
816
817
818
819
820
821
822
# File 'lib/google/cloud/bigquery/data_transfer/v1/data_transfer_service_client.rb', line 810

def list_transfer_logs \
    parent,
    page_size: nil,
    message_types: nil,
    options: nil
  req = {
    parent: parent,
    page_size: page_size,
    message_types: message_types
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::ListTransferLogsRequest)
  @list_transfer_logs.call(req, options)
end

#list_transfer_runs(parent, states: nil, page_size: nil, run_attempt: nil, options: nil) ⇒ Google::Gax::PagedEnumerable<Google::Cloud::Bigquery::DataTransfer::V1::TransferRun>

Returns information about running and completed jobs.

Examples:

require "google/cloud/bigquery/data_transfer/v1"

data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
formatted_parent = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient.project_transfer_config_path("[PROJECT]", "[TRANSFER_CONFIG]")

# Iterate over all results.
data_transfer_service_client.list_transfer_runs(formatted_parent).each do |element|
  # Process element.
end

# Or iterate over results one page at a time.
data_transfer_service_client.list_transfer_runs(formatted_parent).each_page do |page|
  # Process each page at a time.
  page.each do |element|
    # Process element.
  end
end

Parameters:

  • parent (String)

    Name of transfer configuration for which transfer runs should be retrieved. Format of transfer configuration resource name is: +projects/project_id/transferConfigs/config_id+.

  • states (Array<Google::Cloud::Bigquery::DataTransfer::V1::TransferState>)

    When specified, only transfer runs with requested states are returned.

  • page_size (Integer)

    The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

  • run_attempt (Google::Cloud::Bigquery::DataTransfer::V1::ListTransferRunsRequest::RunAttempt)

    Indicates how run attempts are to be pulled.

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Returns:

  • (Google::Gax::PagedEnumerable<Google::Cloud::Bigquery::DataTransfer::V1::TransferRun>)

    An enumerable of Google::Cloud::Bigquery::DataTransfer::V1::TransferRun instances. See Google::Gax::PagedEnumerable documentation for other operations such as per-page iteration or access to the response object.

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
# File 'lib/google/cloud/bigquery/data_transfer/v1/data_transfer_service_client.rb', line 752

def list_transfer_runs \
    parent,
    states: nil,
    page_size: nil,
    run_attempt: nil,
    options: nil
  req = {
    parent: parent,
    states: states,
    page_size: page_size,
    run_attempt: run_attempt
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::ListTransferRunsRequest)
  @list_transfer_runs.call(req, options)
end

#schedule_transfer_runs(parent, start_time, end_time, options: nil) ⇒ Google::Cloud::Bigquery::DataTransfer::V1::ScheduleTransferRunsResponse

Creates transfer runs for a time range [start_time, end_time]. For each date - or whatever granularity the data source supports - in the range, one transfer run is created. Note that runs are created per UTC time in the time range.

Examples:

require "google/cloud/bigquery/data_transfer/v1"

data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new
formatted_parent = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferServiceClient.project_transfer_config_path("[PROJECT]", "[TRANSFER_CONFIG]")

# TODO: Initialize +start_time+:
start_time = {}

# TODO: Initialize +end_time+:
end_time = {}
response = data_transfer_service_client.schedule_transfer_runs(formatted_parent, start_time, end_time)

Parameters:

  • parent (String)

    Transfer configuration name in the form: +projects/project_id/transferConfigs/config_id+.

  • start_time (Google::Protobuf::Timestamp | Hash)

    Start time of the range of transfer runs. For example, +"2017-05-25T00:00:00+00:00"+. A hash of the same form as Google::Protobuf::Timestamp can also be provided.

  • end_time (Google::Protobuf::Timestamp | Hash)

    End time of the range of transfer runs. For example, +"2017-05-30T00:00:00+00:00"+. A hash of the same form as Google::Protobuf::Timestamp can also be provided.

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



640
641
642
643
644
645
646
647
648
649
650
651
652
# File 'lib/google/cloud/bigquery/data_transfer/v1/data_transfer_service_client.rb', line 640

def schedule_transfer_runs \
    parent,
    start_time,
    end_time,
    options: nil
  req = {
    parent: parent,
    start_time: start_time,
    end_time: end_time
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::ScheduleTransferRunsRequest)
  @schedule_transfer_runs.call(req, options)
end

#update_transfer_config(transfer_config, update_mask, authorization_code: nil, options: nil) ⇒ Google::Cloud::Bigquery::DataTransfer::V1::TransferConfig

Updates a data transfer configuration. All fields must be set, even if they are not updated.

Examples:

require "google/cloud/bigquery/data_transfer/v1"

data_transfer_service_client = Google::Cloud::Bigquery::DataTransfer::V1.new

# TODO: Initialize +transfer_config+:
transfer_config = {}

# TODO: Initialize +update_mask+:
update_mask = {}
response = data_transfer_service_client.update_transfer_config(transfer_config, update_mask)

Parameters:

  • transfer_config (Google::Cloud::Bigquery::DataTransfer::V1::TransferConfig | Hash)

    Data transfer configuration to create. A hash of the same form as Google::Cloud::Bigquery::DataTransfer::V1::TransferConfig can also be provided.

  • update_mask (Google::Protobuf::FieldMask | Hash)

    Required list of fields to be updated in this request. A hash of the same form as Google::Protobuf::FieldMask can also be provided.

  • authorization_code (String)

    Optional OAuth2 authorization code to use with this transfer configuration. If it is provided, the transfer configuration will be associated with the authorizing user. In order to obtain authorization_code, please make a request to https://www.gstatic.com/bigquerydatatransfer/oauthz/auth?client_id=&scope=&redirect_uri=

    • client_id should be OAuth client_id of BigQuery DTS API for the given data source returned by ListDataSources method.
    • data_source_scopes are the scopes returned by ListDataSources method.
    • redirect_uri is an optional parameter. If not specified, then authorization code is posted to the opener of authorization flow window. Otherwise it will be sent to the redirect uri. A special value of urn:ietf:wg:oauth:2.0:oob means that authorization code should be returned in the title bar of the browser, with the page text prompting the user to copy the code and paste it in the application.
  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



480
481
482
483
484
485
486
487
488
489
490
491
492
# File 'lib/google/cloud/bigquery/data_transfer/v1/data_transfer_service_client.rb', line 480

def update_transfer_config \
    transfer_config,
    update_mask,
    authorization_code: nil,
    options: nil
  req = {
    transfer_config: transfer_config,
    update_mask: update_mask,
    authorization_code: authorization_code
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Bigquery::DataTransfer::V1::UpdateTransferConfigRequest)
  @update_transfer_config.call(req, options)
end