google-cloud-firestore-admin-v1 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,6 +28,32 @@ module Google
28
28
  ##
29
29
  # Client for the FirestoreAdmin service.
30
30
  #
31
+ # The Cloud Firestore Admin API.
32
+ #
33
+ # This API provides several administrative services for Cloud Firestore.
34
+ #
35
+ # Project, Database, Namespace, Collection, Collection Group, and Document are
36
+ # used as defined in the Google Cloud Firestore API.
37
+ #
38
+ # Operation: An Operation represents work being performed in the background.
39
+ #
40
+ # The index service manages Cloud Firestore indexes.
41
+ #
42
+ # Index creation is performed asynchronously.
43
+ # An Operation resource is created for each such asynchronous operation.
44
+ # The state of the operation (including any errors encountered)
45
+ # may be queried via the Operation resource.
46
+ #
47
+ # The Operations collection provides a record of actions performed for the
48
+ # specified Project (including any Operations in progress). Operations are not
49
+ # created directly but through calls on other collections or resources.
50
+ #
51
+ # An Operation that is done may be deleted so that it is no longer listed as
52
+ # part of the Operation collection. Operations are garbage collected after
53
+ # 30 days. By default, ListOperations will only return in progress and failed
54
+ # operations. To list completed operation, issue a ListOperations request with
55
+ # the filter `done: true`.
56
+ #
31
57
  # Operations are created by service `FirestoreAdmin`, but are accessed via
32
58
  # service `google.longrunning.Operations`.
33
59
  #
@@ -43,13 +69,12 @@ module Google
43
69
  # See {::Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client::Configuration}
44
70
  # for a description of the configuration fields.
45
71
  #
46
- # ## Example
47
- #
48
- # To modify the configuration for all FirestoreAdmin clients:
72
+ # @example
49
73
  #
50
- # ::Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client.configure do |config|
51
- # config.timeout = 10.0
52
- # end
74
+ # # Modify the configuration for all FirestoreAdmin clients
75
+ # ::Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client.configure do |config|
76
+ # config.timeout = 10.0
77
+ # end
53
78
  #
54
79
  # @yield [config] Configure the Client client.
55
80
  # @yieldparam config [Client::Configuration]
@@ -129,19 +154,15 @@ module Google
129
154
  ##
130
155
  # Create a new FirestoreAdmin client object.
131
156
  #
132
- # ## Examples
157
+ # @example
133
158
  #
134
- # To create a new FirestoreAdmin client with the default
135
- # configuration:
159
+ # # Create a client using the default configuration
160
+ # client = ::Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client.new
136
161
  #
137
- # client = ::Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client.new
138
- #
139
- # To create a new FirestoreAdmin client with a custom
140
- # configuration:
141
- #
142
- # client = ::Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client.new do |config|
143
- # config.timeout = 10.0
144
- # end
162
+ # # Create a client using a custom configuration
163
+ # client = ::Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client.new do |config|
164
+ # config.timeout = 10.0
165
+ # end
145
166
  #
146
167
  # @yield [config] Configure the FirestoreAdmin client.
147
168
  # @yieldparam config [Client::Configuration]
@@ -161,10 +182,9 @@ module Google
161
182
 
162
183
  # Create credentials
163
184
  credentials = @config.credentials
164
- # Use self-signed JWT if the scope and endpoint are unchanged from default,
185
+ # Use self-signed JWT if the endpoint is unchanged from default,
165
186
  # but only if the default endpoint does not have a region prefix.
166
- enable_self_signed_jwt = @config.scope == Client.configure.scope &&
167
- @config.endpoint == Client.configure.endpoint &&
187
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
168
188
  !@config.endpoint.split(".").first.include?("-")
169
189
  credentials ||= Credentials.default scope: @config.scope,
170
190
  enable_self_signed_jwt: enable_self_signed_jwt
@@ -176,6 +196,7 @@ module Google
176
196
 
177
197
  @operations_client = Operations.new do |config|
178
198
  config.credentials = credentials
199
+ config.quota_project = @quota_project_id
179
200
  config.endpoint = @config.endpoint
180
201
  end
181
202
 
@@ -231,6 +252,28 @@ module Google
231
252
  #
232
253
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
233
254
  #
255
+ # @example Basic example
256
+ # require "google/cloud/firestore/admin/v1"
257
+ #
258
+ # # Create a client object. The client can be reused for multiple calls.
259
+ # client = Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client.new
260
+ #
261
+ # # Create a request. To set request fields, pass in keyword arguments.
262
+ # request = Google::Cloud::Firestore::Admin::V1::CreateIndexRequest.new
263
+ #
264
+ # # Call the create_index method.
265
+ # result = client.create_index request
266
+ #
267
+ # # The returned object is of type Gapic::Operation. You can use this
268
+ # # object to check the status of an operation, cancel it, or wait
269
+ # # for results. Here is how to block until completion:
270
+ # result.wait_until_done! timeout: 60
271
+ # if result.response?
272
+ # p result.response
273
+ # else
274
+ # puts "Error!"
275
+ # end
276
+ #
234
277
  def create_index request, options = nil
235
278
  raise ::ArgumentError, "request must be provided" if request.nil?
236
279
 
@@ -248,16 +291,20 @@ module Google
248
291
  gapic_version: ::Google::Cloud::Firestore::Admin::V1::VERSION
249
292
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
250
293
 
251
- header_params = {
252
- "parent" => request.parent
253
- }
294
+ header_params = {}
295
+ if request.parent
296
+ header_params["parent"] = request.parent
297
+ end
298
+
254
299
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
255
300
  metadata[:"x-goog-request-params"] ||= request_params_header
256
301
 
257
302
  options.apply_defaults timeout: @config.rpcs.create_index.timeout,
258
303
  metadata: metadata,
259
304
  retry_policy: @config.rpcs.create_index.retry_policy
260
- options.apply_defaults metadata: @config.metadata,
305
+
306
+ options.apply_defaults timeout: @config.timeout,
307
+ metadata: @config.metadata,
261
308
  retry_policy: @config.retry_policy
262
309
 
263
310
  @firestore_admin_stub.call_rpc :create_index, request, options: options do |response, operation|
@@ -307,6 +354,27 @@ module Google
307
354
  #
308
355
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
309
356
  #
357
+ # @example Basic example
358
+ # require "google/cloud/firestore/admin/v1"
359
+ #
360
+ # # Create a client object. The client can be reused for multiple calls.
361
+ # client = Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client.new
362
+ #
363
+ # # Create a request. To set request fields, pass in keyword arguments.
364
+ # request = Google::Cloud::Firestore::Admin::V1::ListIndexesRequest.new
365
+ #
366
+ # # Call the list_indexes method.
367
+ # result = client.list_indexes request
368
+ #
369
+ # # The returned object is of type Gapic::PagedEnumerable. You can
370
+ # # iterate over all elements by calling #each, and the enumerable
371
+ # # will lazily make API calls to fetch subsequent pages. Other
372
+ # # methods are also available for managing paging directly.
373
+ # result.each do |response|
374
+ # # Each element is of type ::Google::Cloud::Firestore::Admin::V1::Index.
375
+ # p response
376
+ # end
377
+ #
310
378
  def list_indexes request, options = nil
311
379
  raise ::ArgumentError, "request must be provided" if request.nil?
312
380
 
@@ -324,16 +392,20 @@ module Google
324
392
  gapic_version: ::Google::Cloud::Firestore::Admin::V1::VERSION
325
393
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
326
394
 
327
- header_params = {
328
- "parent" => request.parent
329
- }
395
+ header_params = {}
396
+ if request.parent
397
+ header_params["parent"] = request.parent
398
+ end
399
+
330
400
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
331
401
  metadata[:"x-goog-request-params"] ||= request_params_header
332
402
 
333
403
  options.apply_defaults timeout: @config.rpcs.list_indexes.timeout,
334
404
  metadata: metadata,
335
405
  retry_policy: @config.rpcs.list_indexes.retry_policy
336
- options.apply_defaults metadata: @config.metadata,
406
+
407
+ options.apply_defaults timeout: @config.timeout,
408
+ metadata: @config.metadata,
337
409
  retry_policy: @config.retry_policy
338
410
 
339
411
  @firestore_admin_stub.call_rpc :list_indexes, request, options: options do |response, operation|
@@ -375,6 +447,21 @@ module Google
375
447
  #
376
448
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
377
449
  #
450
+ # @example Basic example
451
+ # require "google/cloud/firestore/admin/v1"
452
+ #
453
+ # # Create a client object. The client can be reused for multiple calls.
454
+ # client = Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client.new
455
+ #
456
+ # # Create a request. To set request fields, pass in keyword arguments.
457
+ # request = Google::Cloud::Firestore::Admin::V1::GetIndexRequest.new
458
+ #
459
+ # # Call the get_index method.
460
+ # result = client.get_index request
461
+ #
462
+ # # The returned object is of type Google::Cloud::Firestore::Admin::V1::Index.
463
+ # p result
464
+ #
378
465
  def get_index request, options = nil
379
466
  raise ::ArgumentError, "request must be provided" if request.nil?
380
467
 
@@ -392,16 +479,20 @@ module Google
392
479
  gapic_version: ::Google::Cloud::Firestore::Admin::V1::VERSION
393
480
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
394
481
 
395
- header_params = {
396
- "name" => request.name
397
- }
482
+ header_params = {}
483
+ if request.name
484
+ header_params["name"] = request.name
485
+ end
486
+
398
487
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
399
488
  metadata[:"x-goog-request-params"] ||= request_params_header
400
489
 
401
490
  options.apply_defaults timeout: @config.rpcs.get_index.timeout,
402
491
  metadata: metadata,
403
492
  retry_policy: @config.rpcs.get_index.retry_policy
404
- options.apply_defaults metadata: @config.metadata,
493
+
494
+ options.apply_defaults timeout: @config.timeout,
495
+ metadata: @config.metadata,
405
496
  retry_policy: @config.retry_policy
406
497
 
407
498
  @firestore_admin_stub.call_rpc :get_index, request, options: options do |response, operation|
@@ -442,6 +533,21 @@ module Google
442
533
  #
443
534
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
444
535
  #
536
+ # @example Basic example
537
+ # require "google/cloud/firestore/admin/v1"
538
+ #
539
+ # # Create a client object. The client can be reused for multiple calls.
540
+ # client = Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client.new
541
+ #
542
+ # # Create a request. To set request fields, pass in keyword arguments.
543
+ # request = Google::Cloud::Firestore::Admin::V1::DeleteIndexRequest.new
544
+ #
545
+ # # Call the delete_index method.
546
+ # result = client.delete_index request
547
+ #
548
+ # # The returned object is of type Google::Protobuf::Empty.
549
+ # p result
550
+ #
445
551
  def delete_index request, options = nil
446
552
  raise ::ArgumentError, "request must be provided" if request.nil?
447
553
 
@@ -459,16 +565,20 @@ module Google
459
565
  gapic_version: ::Google::Cloud::Firestore::Admin::V1::VERSION
460
566
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
461
567
 
462
- header_params = {
463
- "name" => request.name
464
- }
568
+ header_params = {}
569
+ if request.name
570
+ header_params["name"] = request.name
571
+ end
572
+
465
573
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
466
574
  metadata[:"x-goog-request-params"] ||= request_params_header
467
575
 
468
576
  options.apply_defaults timeout: @config.rpcs.delete_index.timeout,
469
577
  metadata: metadata,
470
578
  retry_policy: @config.rpcs.delete_index.retry_policy
471
- options.apply_defaults metadata: @config.metadata,
579
+
580
+ options.apply_defaults timeout: @config.timeout,
581
+ metadata: @config.metadata,
472
582
  retry_policy: @config.retry_policy
473
583
 
474
584
  @firestore_admin_stub.call_rpc :delete_index, request, options: options do |response, operation|
@@ -509,6 +619,21 @@ module Google
509
619
  #
510
620
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
511
621
  #
622
+ # @example Basic example
623
+ # require "google/cloud/firestore/admin/v1"
624
+ #
625
+ # # Create a client object. The client can be reused for multiple calls.
626
+ # client = Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client.new
627
+ #
628
+ # # Create a request. To set request fields, pass in keyword arguments.
629
+ # request = Google::Cloud::Firestore::Admin::V1::GetFieldRequest.new
630
+ #
631
+ # # Call the get_field method.
632
+ # result = client.get_field request
633
+ #
634
+ # # The returned object is of type Google::Cloud::Firestore::Admin::V1::Field.
635
+ # p result
636
+ #
512
637
  def get_field request, options = nil
513
638
  raise ::ArgumentError, "request must be provided" if request.nil?
514
639
 
@@ -526,16 +651,20 @@ module Google
526
651
  gapic_version: ::Google::Cloud::Firestore::Admin::V1::VERSION
527
652
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
528
653
 
529
- header_params = {
530
- "name" => request.name
531
- }
654
+ header_params = {}
655
+ if request.name
656
+ header_params["name"] = request.name
657
+ end
658
+
532
659
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
533
660
  metadata[:"x-goog-request-params"] ||= request_params_header
534
661
 
535
662
  options.apply_defaults timeout: @config.rpcs.get_field.timeout,
536
663
  metadata: metadata,
537
664
  retry_policy: @config.rpcs.get_field.retry_policy
538
- options.apply_defaults metadata: @config.metadata,
665
+
666
+ options.apply_defaults timeout: @config.timeout,
667
+ metadata: @config.metadata,
539
668
  retry_policy: @config.retry_policy
540
669
 
541
670
  @firestore_admin_stub.call_rpc :get_field, request, options: options do |response, operation|
@@ -590,6 +719,28 @@ module Google
590
719
  #
591
720
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
592
721
  #
722
+ # @example Basic example
723
+ # require "google/cloud/firestore/admin/v1"
724
+ #
725
+ # # Create a client object. The client can be reused for multiple calls.
726
+ # client = Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client.new
727
+ #
728
+ # # Create a request. To set request fields, pass in keyword arguments.
729
+ # request = Google::Cloud::Firestore::Admin::V1::UpdateFieldRequest.new
730
+ #
731
+ # # Call the update_field method.
732
+ # result = client.update_field request
733
+ #
734
+ # # The returned object is of type Gapic::Operation. You can use this
735
+ # # object to check the status of an operation, cancel it, or wait
736
+ # # for results. Here is how to block until completion:
737
+ # result.wait_until_done! timeout: 60
738
+ # if result.response?
739
+ # p result.response
740
+ # else
741
+ # puts "Error!"
742
+ # end
743
+ #
593
744
  def update_field request, options = nil
594
745
  raise ::ArgumentError, "request must be provided" if request.nil?
595
746
 
@@ -607,16 +758,20 @@ module Google
607
758
  gapic_version: ::Google::Cloud::Firestore::Admin::V1::VERSION
608
759
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
609
760
 
610
- header_params = {
611
- "field.name" => request.field.name
612
- }
761
+ header_params = {}
762
+ if request.field&.name
763
+ header_params["field.name"] = request.field.name
764
+ end
765
+
613
766
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
614
767
  metadata[:"x-goog-request-params"] ||= request_params_header
615
768
 
616
769
  options.apply_defaults timeout: @config.rpcs.update_field.timeout,
617
770
  metadata: metadata,
618
771
  retry_policy: @config.rpcs.update_field.retry_policy
619
- options.apply_defaults metadata: @config.metadata,
772
+
773
+ options.apply_defaults timeout: @config.timeout,
774
+ metadata: @config.metadata,
620
775
  retry_policy: @config.retry_policy
621
776
 
622
777
  @firestore_admin_stub.call_rpc :update_field, request, options: options do |response, operation|
@@ -634,7 +789,7 @@ module Google
634
789
  # Currently, {::Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client#list_fields FirestoreAdmin.ListFields} only supports listing fields
635
790
  # that have been explicitly overridden. To issue this query, call
636
791
  # {::Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client#list_fields FirestoreAdmin.ListFields} with the filter set to
637
- # `indexConfig.usesAncestorConfig:false`.
792
+ # `indexConfig.usesAncestorConfig:false` .
638
793
  #
639
794
  # @overload list_fields(request, options = nil)
640
795
  # Pass arguments to `list_fields` via a request object, either of type
@@ -658,8 +813,8 @@ module Google
658
813
  # The filter to apply to list results. Currently,
659
814
  # {::Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client#list_fields FirestoreAdmin.ListFields} only supports listing fields
660
815
  # that have been explicitly overridden. To issue this query, call
661
- # {::Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client#list_fields FirestoreAdmin.ListFields} with the filter set to
662
- # `indexConfig.usesAncestorConfig:false`.
816
+ # {::Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client#list_fields FirestoreAdmin.ListFields} with a filter that includes
817
+ # `indexConfig.usesAncestorConfig:false` .
663
818
  # @param page_size [::Integer]
664
819
  # The number of results to return.
665
820
  # @param page_token [::String]
@@ -675,6 +830,27 @@ module Google
675
830
  #
676
831
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
677
832
  #
833
+ # @example Basic example
834
+ # require "google/cloud/firestore/admin/v1"
835
+ #
836
+ # # Create a client object. The client can be reused for multiple calls.
837
+ # client = Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client.new
838
+ #
839
+ # # Create a request. To set request fields, pass in keyword arguments.
840
+ # request = Google::Cloud::Firestore::Admin::V1::ListFieldsRequest.new
841
+ #
842
+ # # Call the list_fields method.
843
+ # result = client.list_fields request
844
+ #
845
+ # # The returned object is of type Gapic::PagedEnumerable. You can
846
+ # # iterate over all elements by calling #each, and the enumerable
847
+ # # will lazily make API calls to fetch subsequent pages. Other
848
+ # # methods are also available for managing paging directly.
849
+ # result.each do |response|
850
+ # # Each element is of type ::Google::Cloud::Firestore::Admin::V1::Field.
851
+ # p response
852
+ # end
853
+ #
678
854
  def list_fields request, options = nil
679
855
  raise ::ArgumentError, "request must be provided" if request.nil?
680
856
 
@@ -692,16 +868,20 @@ module Google
692
868
  gapic_version: ::Google::Cloud::Firestore::Admin::V1::VERSION
693
869
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
694
870
 
695
- header_params = {
696
- "parent" => request.parent
697
- }
871
+ header_params = {}
872
+ if request.parent
873
+ header_params["parent"] = request.parent
874
+ end
875
+
698
876
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
699
877
  metadata[:"x-goog-request-params"] ||= request_params_header
700
878
 
701
879
  options.apply_defaults timeout: @config.rpcs.list_fields.timeout,
702
880
  metadata: metadata,
703
881
  retry_policy: @config.rpcs.list_fields.retry_policy
704
- options.apply_defaults metadata: @config.metadata,
882
+
883
+ options.apply_defaults timeout: @config.timeout,
884
+ metadata: @config.metadata,
705
885
  retry_policy: @config.retry_policy
706
886
 
707
887
  @firestore_admin_stub.call_rpc :list_fields, request, options: options do |response, operation|
@@ -723,6 +903,9 @@ module Google
723
903
  # cancelled before completion it may leave partial data behind in Google
724
904
  # Cloud Storage.
725
905
  #
906
+ # For more details on export behavior and output format, refer to:
907
+ # https://cloud.google.com/firestore/docs/manage-data/export-import
908
+ #
726
909
  # @overload export_documents(request, options = nil)
727
910
  # Pass arguments to `export_documents` via a request object, either of type
728
911
  # {::Google::Cloud::Firestore::Admin::V1::ExportDocumentsRequest} or an equivalent Hash.
@@ -761,6 +944,28 @@ module Google
761
944
  #
762
945
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
763
946
  #
947
+ # @example Basic example
948
+ # require "google/cloud/firestore/admin/v1"
949
+ #
950
+ # # Create a client object. The client can be reused for multiple calls.
951
+ # client = Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client.new
952
+ #
953
+ # # Create a request. To set request fields, pass in keyword arguments.
954
+ # request = Google::Cloud::Firestore::Admin::V1::ExportDocumentsRequest.new
955
+ #
956
+ # # Call the export_documents method.
957
+ # result = client.export_documents request
958
+ #
959
+ # # The returned object is of type Gapic::Operation. You can use this
960
+ # # object to check the status of an operation, cancel it, or wait
961
+ # # for results. Here is how to block until completion:
962
+ # result.wait_until_done! timeout: 60
963
+ # if result.response?
964
+ # p result.response
965
+ # else
966
+ # puts "Error!"
967
+ # end
968
+ #
764
969
  def export_documents request, options = nil
765
970
  raise ::ArgumentError, "request must be provided" if request.nil?
766
971
 
@@ -778,16 +983,20 @@ module Google
778
983
  gapic_version: ::Google::Cloud::Firestore::Admin::V1::VERSION
779
984
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
780
985
 
781
- header_params = {
782
- "name" => request.name
783
- }
986
+ header_params = {}
987
+ if request.name
988
+ header_params["name"] = request.name
989
+ end
990
+
784
991
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
785
992
  metadata[:"x-goog-request-params"] ||= request_params_header
786
993
 
787
994
  options.apply_defaults timeout: @config.rpcs.export_documents.timeout,
788
995
  metadata: metadata,
789
996
  retry_policy: @config.rpcs.export_documents.retry_policy
790
- options.apply_defaults metadata: @config.metadata,
997
+
998
+ options.apply_defaults timeout: @config.timeout,
999
+ metadata: @config.metadata,
791
1000
  retry_policy: @config.retry_policy
792
1001
 
793
1002
  @firestore_admin_stub.call_rpc :export_documents, request, options: options do |response, operation|
@@ -842,6 +1051,28 @@ module Google
842
1051
  #
843
1052
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
844
1053
  #
1054
+ # @example Basic example
1055
+ # require "google/cloud/firestore/admin/v1"
1056
+ #
1057
+ # # Create a client object. The client can be reused for multiple calls.
1058
+ # client = Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client.new
1059
+ #
1060
+ # # Create a request. To set request fields, pass in keyword arguments.
1061
+ # request = Google::Cloud::Firestore::Admin::V1::ImportDocumentsRequest.new
1062
+ #
1063
+ # # Call the import_documents method.
1064
+ # result = client.import_documents request
1065
+ #
1066
+ # # The returned object is of type Gapic::Operation. You can use this
1067
+ # # object to check the status of an operation, cancel it, or wait
1068
+ # # for results. Here is how to block until completion:
1069
+ # result.wait_until_done! timeout: 60
1070
+ # if result.response?
1071
+ # p result.response
1072
+ # else
1073
+ # puts "Error!"
1074
+ # end
1075
+ #
845
1076
  def import_documents request, options = nil
846
1077
  raise ::ArgumentError, "request must be provided" if request.nil?
847
1078
 
@@ -859,16 +1090,20 @@ module Google
859
1090
  gapic_version: ::Google::Cloud::Firestore::Admin::V1::VERSION
860
1091
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
861
1092
 
862
- header_params = {
863
- "name" => request.name
864
- }
1093
+ header_params = {}
1094
+ if request.name
1095
+ header_params["name"] = request.name
1096
+ end
1097
+
865
1098
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
866
1099
  metadata[:"x-goog-request-params"] ||= request_params_header
867
1100
 
868
1101
  options.apply_defaults timeout: @config.rpcs.import_documents.timeout,
869
1102
  metadata: metadata,
870
1103
  retry_policy: @config.rpcs.import_documents.retry_policy
871
- options.apply_defaults metadata: @config.metadata,
1104
+
1105
+ options.apply_defaults timeout: @config.timeout,
1106
+ metadata: @config.metadata,
872
1107
  retry_policy: @config.retry_policy
873
1108
 
874
1109
  @firestore_admin_stub.call_rpc :import_documents, request, options: options do |response, operation|
@@ -880,6 +1115,273 @@ module Google
880
1115
  raise ::Google::Cloud::Error.from_error(e)
881
1116
  end
882
1117
 
1118
+ ##
1119
+ # Gets information about a database.
1120
+ #
1121
+ # @overload get_database(request, options = nil)
1122
+ # Pass arguments to `get_database` via a request object, either of type
1123
+ # {::Google::Cloud::Firestore::Admin::V1::GetDatabaseRequest} or an equivalent Hash.
1124
+ #
1125
+ # @param request [::Google::Cloud::Firestore::Admin::V1::GetDatabaseRequest, ::Hash]
1126
+ # A request object representing the call parameters. Required. To specify no
1127
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1128
+ # @param options [::Gapic::CallOptions, ::Hash]
1129
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1130
+ #
1131
+ # @overload get_database(name: nil)
1132
+ # Pass arguments to `get_database` via keyword arguments. Note that at
1133
+ # least one keyword argument is required. To specify no parameters, or to keep all
1134
+ # the default parameter values, pass an empty Hash as a request object (see above).
1135
+ #
1136
+ # @param name [::String]
1137
+ # Required. A name of the form
1138
+ # `projects/{project_id}/databases/{database_id}`
1139
+ #
1140
+ # @yield [response, operation] Access the result along with the RPC operation
1141
+ # @yieldparam response [::Google::Cloud::Firestore::Admin::V1::Database]
1142
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1143
+ #
1144
+ # @return [::Google::Cloud::Firestore::Admin::V1::Database]
1145
+ #
1146
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1147
+ #
1148
+ # @example Basic example
1149
+ # require "google/cloud/firestore/admin/v1"
1150
+ #
1151
+ # # Create a client object. The client can be reused for multiple calls.
1152
+ # client = Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client.new
1153
+ #
1154
+ # # Create a request. To set request fields, pass in keyword arguments.
1155
+ # request = Google::Cloud::Firestore::Admin::V1::GetDatabaseRequest.new
1156
+ #
1157
+ # # Call the get_database method.
1158
+ # result = client.get_database request
1159
+ #
1160
+ # # The returned object is of type Google::Cloud::Firestore::Admin::V1::Database.
1161
+ # p result
1162
+ #
1163
+ def get_database request, options = nil
1164
+ raise ::ArgumentError, "request must be provided" if request.nil?
1165
+
1166
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::Admin::V1::GetDatabaseRequest
1167
+
1168
+ # Converts hash and nil to an options object
1169
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1170
+
1171
+ # Customize the options with defaults
1172
+ metadata = @config.rpcs.get_database.metadata.to_h
1173
+
1174
+ # Set x-goog-api-client and x-goog-user-project headers
1175
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1176
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1177
+ gapic_version: ::Google::Cloud::Firestore::Admin::V1::VERSION
1178
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1179
+
1180
+ header_params = {}
1181
+ if request.name
1182
+ header_params["name"] = request.name
1183
+ end
1184
+
1185
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1186
+ metadata[:"x-goog-request-params"] ||= request_params_header
1187
+
1188
+ options.apply_defaults timeout: @config.rpcs.get_database.timeout,
1189
+ metadata: metadata,
1190
+ retry_policy: @config.rpcs.get_database.retry_policy
1191
+
1192
+ options.apply_defaults timeout: @config.timeout,
1193
+ metadata: @config.metadata,
1194
+ retry_policy: @config.retry_policy
1195
+
1196
+ @firestore_admin_stub.call_rpc :get_database, request, options: options do |response, operation|
1197
+ yield response, operation if block_given?
1198
+ return response
1199
+ end
1200
+ rescue ::GRPC::BadStatus => e
1201
+ raise ::Google::Cloud::Error.from_error(e)
1202
+ end
1203
+
1204
+ ##
1205
+ # List all the databases in the project.
1206
+ #
1207
+ # @overload list_databases(request, options = nil)
1208
+ # Pass arguments to `list_databases` via a request object, either of type
1209
+ # {::Google::Cloud::Firestore::Admin::V1::ListDatabasesRequest} or an equivalent Hash.
1210
+ #
1211
+ # @param request [::Google::Cloud::Firestore::Admin::V1::ListDatabasesRequest, ::Hash]
1212
+ # A request object representing the call parameters. Required. To specify no
1213
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1214
+ # @param options [::Gapic::CallOptions, ::Hash]
1215
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1216
+ #
1217
+ # @overload list_databases(parent: nil)
1218
+ # Pass arguments to `list_databases` via keyword arguments. Note that at
1219
+ # least one keyword argument is required. To specify no parameters, or to keep all
1220
+ # the default parameter values, pass an empty Hash as a request object (see above).
1221
+ #
1222
+ # @param parent [::String]
1223
+ # Required. A parent name of the form
1224
+ # `projects/{project_id}`
1225
+ #
1226
+ # @yield [response, operation] Access the result along with the RPC operation
1227
+ # @yieldparam response [::Google::Cloud::Firestore::Admin::V1::ListDatabasesResponse]
1228
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1229
+ #
1230
+ # @return [::Google::Cloud::Firestore::Admin::V1::ListDatabasesResponse]
1231
+ #
1232
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1233
+ #
1234
+ # @example Basic example
1235
+ # require "google/cloud/firestore/admin/v1"
1236
+ #
1237
+ # # Create a client object. The client can be reused for multiple calls.
1238
+ # client = Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client.new
1239
+ #
1240
+ # # Create a request. To set request fields, pass in keyword arguments.
1241
+ # request = Google::Cloud::Firestore::Admin::V1::ListDatabasesRequest.new
1242
+ #
1243
+ # # Call the list_databases method.
1244
+ # result = client.list_databases request
1245
+ #
1246
+ # # The returned object is of type Google::Cloud::Firestore::Admin::V1::ListDatabasesResponse.
1247
+ # p result
1248
+ #
1249
+ def list_databases request, options = nil
1250
+ raise ::ArgumentError, "request must be provided" if request.nil?
1251
+
1252
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::Admin::V1::ListDatabasesRequest
1253
+
1254
+ # Converts hash and nil to an options object
1255
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1256
+
1257
+ # Customize the options with defaults
1258
+ metadata = @config.rpcs.list_databases.metadata.to_h
1259
+
1260
+ # Set x-goog-api-client and x-goog-user-project headers
1261
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1262
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1263
+ gapic_version: ::Google::Cloud::Firestore::Admin::V1::VERSION
1264
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1265
+
1266
+ header_params = {}
1267
+ if request.parent
1268
+ header_params["parent"] = request.parent
1269
+ end
1270
+
1271
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1272
+ metadata[:"x-goog-request-params"] ||= request_params_header
1273
+
1274
+ options.apply_defaults timeout: @config.rpcs.list_databases.timeout,
1275
+ metadata: metadata,
1276
+ retry_policy: @config.rpcs.list_databases.retry_policy
1277
+
1278
+ options.apply_defaults timeout: @config.timeout,
1279
+ metadata: @config.metadata,
1280
+ retry_policy: @config.retry_policy
1281
+
1282
+ @firestore_admin_stub.call_rpc :list_databases, request, options: options do |response, operation|
1283
+ yield response, operation if block_given?
1284
+ return response
1285
+ end
1286
+ rescue ::GRPC::BadStatus => e
1287
+ raise ::Google::Cloud::Error.from_error(e)
1288
+ end
1289
+
1290
+ ##
1291
+ # Updates a database.
1292
+ #
1293
+ # @overload update_database(request, options = nil)
1294
+ # Pass arguments to `update_database` via a request object, either of type
1295
+ # {::Google::Cloud::Firestore::Admin::V1::UpdateDatabaseRequest} or an equivalent Hash.
1296
+ #
1297
+ # @param request [::Google::Cloud::Firestore::Admin::V1::UpdateDatabaseRequest, ::Hash]
1298
+ # A request object representing the call parameters. Required. To specify no
1299
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1300
+ # @param options [::Gapic::CallOptions, ::Hash]
1301
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1302
+ #
1303
+ # @overload update_database(database: nil, update_mask: nil)
1304
+ # Pass arguments to `update_database` via keyword arguments. Note that at
1305
+ # least one keyword argument is required. To specify no parameters, or to keep all
1306
+ # the default parameter values, pass an empty Hash as a request object (see above).
1307
+ #
1308
+ # @param database [::Google::Cloud::Firestore::Admin::V1::Database, ::Hash]
1309
+ # Required. The database to update.
1310
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
1311
+ # The list of fields to be updated.
1312
+ #
1313
+ # @yield [response, operation] Access the result along with the RPC operation
1314
+ # @yieldparam response [::Gapic::Operation]
1315
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1316
+ #
1317
+ # @return [::Gapic::Operation]
1318
+ #
1319
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1320
+ #
1321
+ # @example Basic example
1322
+ # require "google/cloud/firestore/admin/v1"
1323
+ #
1324
+ # # Create a client object. The client can be reused for multiple calls.
1325
+ # client = Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client.new
1326
+ #
1327
+ # # Create a request. To set request fields, pass in keyword arguments.
1328
+ # request = Google::Cloud::Firestore::Admin::V1::UpdateDatabaseRequest.new
1329
+ #
1330
+ # # Call the update_database method.
1331
+ # result = client.update_database request
1332
+ #
1333
+ # # The returned object is of type Gapic::Operation. You can use this
1334
+ # # object to check the status of an operation, cancel it, or wait
1335
+ # # for results. Here is how to block until completion:
1336
+ # result.wait_until_done! timeout: 60
1337
+ # if result.response?
1338
+ # p result.response
1339
+ # else
1340
+ # puts "Error!"
1341
+ # end
1342
+ #
1343
+ def update_database request, options = nil
1344
+ raise ::ArgumentError, "request must be provided" if request.nil?
1345
+
1346
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::Admin::V1::UpdateDatabaseRequest
1347
+
1348
+ # Converts hash and nil to an options object
1349
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1350
+
1351
+ # Customize the options with defaults
1352
+ metadata = @config.rpcs.update_database.metadata.to_h
1353
+
1354
+ # Set x-goog-api-client and x-goog-user-project headers
1355
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1356
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1357
+ gapic_version: ::Google::Cloud::Firestore::Admin::V1::VERSION
1358
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1359
+
1360
+ header_params = {}
1361
+ if request.database&.name
1362
+ header_params["database.name"] = request.database.name
1363
+ end
1364
+
1365
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1366
+ metadata[:"x-goog-request-params"] ||= request_params_header
1367
+
1368
+ options.apply_defaults timeout: @config.rpcs.update_database.timeout,
1369
+ metadata: metadata,
1370
+ retry_policy: @config.rpcs.update_database.retry_policy
1371
+
1372
+ options.apply_defaults timeout: @config.timeout,
1373
+ metadata: @config.metadata,
1374
+ retry_policy: @config.retry_policy
1375
+
1376
+ @firestore_admin_stub.call_rpc :update_database, request, options: options do |response, operation|
1377
+ response = ::Gapic::Operation.new response, @operations_client, options: options
1378
+ yield response, operation if block_given?
1379
+ return response
1380
+ end
1381
+ rescue ::GRPC::BadStatus => e
1382
+ raise ::Google::Cloud::Error.from_error(e)
1383
+ end
1384
+
883
1385
  ##
884
1386
  # Configuration class for the FirestoreAdmin API.
885
1387
  #
@@ -893,22 +1395,21 @@ module Google
893
1395
  # Configuration can be applied globally to all clients, or to a single client
894
1396
  # on construction.
895
1397
  #
896
- # # Examples
897
- #
898
- # To modify the global config, setting the timeout for create_index
899
- # to 20 seconds, and all remaining timeouts to 10 seconds:
1398
+ # @example
900
1399
  #
901
- # ::Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client.configure do |config|
902
- # config.timeout = 10.0
903
- # config.rpcs.create_index.timeout = 20.0
904
- # end
1400
+ # # Modify the global config, setting the timeout for
1401
+ # # create_index to 20 seconds,
1402
+ # # and all remaining timeouts to 10 seconds.
1403
+ # ::Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client.configure do |config|
1404
+ # config.timeout = 10.0
1405
+ # config.rpcs.create_index.timeout = 20.0
1406
+ # end
905
1407
  #
906
- # To apply the above configuration only to a new client:
907
- #
908
- # client = ::Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client.new do |config|
909
- # config.timeout = 10.0
910
- # config.rpcs.create_index.timeout = 20.0
911
- # end
1408
+ # # Apply the above configuration only to a new client.
1409
+ # client = ::Google::Cloud::Firestore::Admin::V1::FirestoreAdmin::Client.new do |config|
1410
+ # config.timeout = 10.0
1411
+ # config.rpcs.create_index.timeout = 20.0
1412
+ # end
912
1413
  #
913
1414
  # @!attribute [rw] endpoint
914
1415
  # The hostname or hostname:port of the service endpoint.
@@ -1061,6 +1562,21 @@ module Google
1061
1562
  # @return [::Gapic::Config::Method]
1062
1563
  #
1063
1564
  attr_reader :import_documents
1565
+ ##
1566
+ # RPC-specific configuration for `get_database`
1567
+ # @return [::Gapic::Config::Method]
1568
+ #
1569
+ attr_reader :get_database
1570
+ ##
1571
+ # RPC-specific configuration for `list_databases`
1572
+ # @return [::Gapic::Config::Method]
1573
+ #
1574
+ attr_reader :list_databases
1575
+ ##
1576
+ # RPC-specific configuration for `update_database`
1577
+ # @return [::Gapic::Config::Method]
1578
+ #
1579
+ attr_reader :update_database
1064
1580
 
1065
1581
  # @private
1066
1582
  def initialize parent_rpcs = nil
@@ -1082,6 +1598,12 @@ module Google
1082
1598
  @export_documents = ::Gapic::Config::Method.new export_documents_config
1083
1599
  import_documents_config = parent_rpcs.import_documents if parent_rpcs.respond_to? :import_documents
1084
1600
  @import_documents = ::Gapic::Config::Method.new import_documents_config
1601
+ get_database_config = parent_rpcs.get_database if parent_rpcs.respond_to? :get_database
1602
+ @get_database = ::Gapic::Config::Method.new get_database_config
1603
+ list_databases_config = parent_rpcs.list_databases if parent_rpcs.respond_to? :list_databases
1604
+ @list_databases = ::Gapic::Config::Method.new list_databases_config
1605
+ update_database_config = parent_rpcs.update_database if parent_rpcs.respond_to? :update_database
1606
+ @update_database = ::Gapic::Config::Method.new update_database_config
1085
1607
 
1086
1608
  yield self if block_given?
1087
1609
  end