google-cloud-firestore 1.4.2 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +1 -1
  3. data/CHANGELOG.md +51 -0
  4. data/TROUBLESHOOTING.md +2 -8
  5. data/lib/google-cloud-firestore.rb +15 -21
  6. data/lib/google/cloud/firestore.rb +12 -23
  7. data/lib/google/cloud/firestore/client.rb +12 -14
  8. data/lib/google/cloud/firestore/collection_reference.rb +1 -0
  9. data/lib/google/cloud/firestore/collection_reference_list.rb +137 -0
  10. data/lib/google/cloud/firestore/convert.rb +39 -39
  11. data/lib/google/cloud/firestore/credentials.rb +2 -2
  12. data/lib/google/cloud/firestore/document_reference.rb +8 -8
  13. data/lib/google/cloud/firestore/document_reference/list.rb +2 -2
  14. data/lib/google/cloud/firestore/document_snapshot.rb +4 -4
  15. data/lib/google/cloud/firestore/query.rb +114 -22
  16. data/lib/google/cloud/firestore/service.rb +63 -104
  17. data/lib/google/cloud/firestore/transaction.rb +2 -2
  18. data/lib/google/cloud/firestore/version.rb +1 -1
  19. data/lib/google/cloud/firestore/watch/inventory.rb +2 -0
  20. data/lib/google/cloud/firestore/watch/listener.rb +9 -9
  21. data/lib/google/cloud/firestore/watch/order.rb +1 -1
  22. metadata +9 -107
  23. data/lib/google/cloud/firestore/admin.rb +0 -144
  24. data/lib/google/cloud/firestore/admin/v1.rb +0 -151
  25. data/lib/google/cloud/firestore/admin/v1/credentials.rb +0 -44
  26. data/lib/google/cloud/firestore/admin/v1/doc/google/firestore/admin/v1/field.rb +0 -86
  27. data/lib/google/cloud/firestore/admin/v1/doc/google/firestore/admin/v1/firestore_admin.rb +0 -161
  28. data/lib/google/cloud/firestore/admin/v1/doc/google/firestore/admin/v1/index.rb +0 -142
  29. data/lib/google/cloud/firestore/admin/v1/doc/google/longrunning/operations.rb +0 -51
  30. data/lib/google/cloud/firestore/admin/v1/doc/google/protobuf/any.rb +0 -131
  31. data/lib/google/cloud/firestore/admin/v1/doc/google/protobuf/empty.rb +0 -29
  32. data/lib/google/cloud/firestore/admin/v1/doc/google/protobuf/field_mask.rb +0 -222
  33. data/lib/google/cloud/firestore/admin/v1/doc/google/rpc/status.rb +0 -39
  34. data/lib/google/cloud/firestore/admin/v1/firestore_admin_client.rb +0 -902
  35. data/lib/google/cloud/firestore/admin/v1/firestore_admin_client_config.json +0 -71
  36. data/lib/google/cloud/firestore/v1.rb +0 -152
  37. data/lib/google/cloud/firestore/v1/credentials.rb +0 -42
  38. data/lib/google/cloud/firestore/v1/doc/google/firestore/v1/common.rb +0 -64
  39. data/lib/google/cloud/firestore/v1/doc/google/firestore/v1/document.rb +0 -136
  40. data/lib/google/cloud/firestore/v1/doc/google/firestore/v1/firestore.rb +0 -566
  41. data/lib/google/cloud/firestore/v1/doc/google/firestore/v1/query.rb +0 -227
  42. data/lib/google/cloud/firestore/v1/doc/google/firestore/v1/write.rb +0 -241
  43. data/lib/google/cloud/firestore/v1/doc/google/protobuf/any.rb +0 -131
  44. data/lib/google/cloud/firestore/v1/doc/google/protobuf/empty.rb +0 -29
  45. data/lib/google/cloud/firestore/v1/doc/google/protobuf/timestamp.rb +0 -113
  46. data/lib/google/cloud/firestore/v1/doc/google/protobuf/wrappers.rb +0 -26
  47. data/lib/google/cloud/firestore/v1/doc/google/rpc/status.rb +0 -39
  48. data/lib/google/cloud/firestore/v1/firestore_client.rb +0 -1011
  49. data/lib/google/cloud/firestore/v1/firestore_client_config.json +0 -100
  50. data/lib/google/cloud/firestore/v1beta1.rb +0 -162
  51. data/lib/google/cloud/firestore/v1beta1/credentials.rb +0 -42
  52. data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/common.rb +0 -64
  53. data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/document.rb +0 -136
  54. data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/firestore.rb +0 -564
  55. data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/query.rb +0 -227
  56. data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/write.rb +0 -237
  57. data/lib/google/cloud/firestore/v1beta1/doc/google/protobuf/any.rb +0 -131
  58. data/lib/google/cloud/firestore/v1beta1/doc/google/protobuf/empty.rb +0 -29
  59. data/lib/google/cloud/firestore/v1beta1/doc/google/protobuf/timestamp.rb +0 -113
  60. data/lib/google/cloud/firestore/v1beta1/doc/google/protobuf/wrappers.rb +0 -26
  61. data/lib/google/cloud/firestore/v1beta1/doc/google/rpc/status.rb +0 -39
  62. data/lib/google/cloud/firestore/v1beta1/firestore_client.rb +0 -1021
  63. data/lib/google/cloud/firestore/v1beta1/firestore_client_config.json +0 -100
  64. data/lib/google/firestore/admin/v1/field_pb.rb +0 -32
  65. data/lib/google/firestore/admin/v1/firestore_admin_pb.rb +0 -84
  66. data/lib/google/firestore/admin/v1/firestore_admin_services_pb.rb +0 -94
  67. data/lib/google/firestore/admin/v1/index_pb.rb +0 -58
  68. data/lib/google/firestore/admin/v1/location_pb.rb +0 -22
  69. data/lib/google/firestore/admin/v1/operation_pb.rb +0 -90
  70. data/lib/google/firestore/v1/common_pb.rb +0 -45
  71. data/lib/google/firestore/v1/document_pb.rb +0 -50
  72. data/lib/google/firestore/v1/firestore_pb.rb +0 -222
  73. data/lib/google/firestore/v1/firestore_services_pb.rb +0 -80
  74. data/lib/google/firestore/v1/query_pb.rb +0 -107
  75. data/lib/google/firestore/v1/write_pb.rb +0 -80
  76. data/lib/google/firestore/v1beta1/common_pb.rb +0 -45
  77. data/lib/google/firestore/v1beta1/document_pb.rb +0 -50
  78. data/lib/google/firestore/v1beta1/firestore_pb.rb +0 -222
  79. data/lib/google/firestore/v1beta1/firestore_services_pb.rb +0 -89
  80. data/lib/google/firestore/v1beta1/query_pb.rb +0 -107
  81. data/lib/google/firestore/v1beta1/write_pb.rb +0 -79
@@ -1,39 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Rpc
18
- # The `Status` type defines a logical error model that is suitable for
19
- # different programming environments, including REST APIs and RPC APIs. It is
20
- # used by [gRPC](https://github.com/grpc). Each `Status` message contains
21
- # three pieces of data: error code, error message, and error details.
22
- #
23
- # You can find out more about this error model and how to work with it in the
24
- # [API Design Guide](https://cloud.google.com/apis/design/errors).
25
- # @!attribute [rw] code
26
- # @return [Integer]
27
- # The status code, which should be an enum value of {Google::Rpc::Code}.
28
- # @!attribute [rw] message
29
- # @return [String]
30
- # A developer-facing error message, which should be in English. Any
31
- # user-facing error message should be localized and sent in the
32
- # {Google::Rpc::Status#details} field, or localized by the client.
33
- # @!attribute [rw] details
34
- # @return [Array<Google::Protobuf::Any>]
35
- # A list of messages that carry the error details. There is a common set of
36
- # message types for APIs to use.
37
- class Status; end
38
- end
39
- end
@@ -1,902 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #
15
- # EDITING INSTRUCTIONS
16
- # This file was generated from the file
17
- # https://github.com/googleapis/googleapis/blob/master/google/firestore/admin/v1/firestore_admin.proto,
18
- # and updates to that file get reflected here through a refresh process.
19
- # For the short term, the refresh process will only be runnable by Google
20
- # engineers.
21
-
22
-
23
- require "json"
24
- require "pathname"
25
-
26
- require "google/gax"
27
- require "google/gax/operation"
28
- require "google/longrunning/operations_client"
29
-
30
- require "google/firestore/admin/v1/firestore_admin_pb"
31
- require "google/cloud/firestore/admin/v1/credentials"
32
- require "google/cloud/firestore/version"
33
-
34
- module Google
35
- module Cloud
36
- module Firestore
37
- module Admin
38
- module V1
39
- # Operations are created by service `FirestoreAdmin`, but are accessed via
40
- # service `google.longrunning.Operations`.
41
- #
42
- # @!attribute [r] firestore_admin_stub
43
- # @return [Google::Firestore::Admin::V1::FirestoreAdmin::Stub]
44
- class FirestoreAdminClient
45
- # @private
46
- attr_reader :firestore_admin_stub
47
-
48
- # The default address of the service.
49
- SERVICE_ADDRESS = "firestore.googleapis.com".freeze
50
-
51
- # The default port of the service.
52
- DEFAULT_SERVICE_PORT = 443
53
-
54
- # The default set of gRPC interceptors.
55
- GRPC_INTERCEPTORS = []
56
-
57
- DEFAULT_TIMEOUT = 30
58
-
59
- PAGE_DESCRIPTORS = {
60
- "list_indexes" => Google::Gax::PageDescriptor.new(
61
- "page_token",
62
- "next_page_token",
63
- "indexes"),
64
- "list_fields" => Google::Gax::PageDescriptor.new(
65
- "page_token",
66
- "next_page_token",
67
- "fields")
68
- }.freeze
69
-
70
- private_constant :PAGE_DESCRIPTORS
71
-
72
- # The scopes needed to make gRPC calls to all of the methods defined in
73
- # this service.
74
- ALL_SCOPES = [
75
- "https://www.googleapis.com/auth/cloud-platform",
76
- "https://www.googleapis.com/auth/datastore"
77
- ].freeze
78
-
79
- class OperationsClient < Google::Longrunning::OperationsClient
80
- self::SERVICE_ADDRESS = FirestoreAdminClient::SERVICE_ADDRESS
81
- self::GRPC_INTERCEPTORS = FirestoreAdminClient::GRPC_INTERCEPTORS
82
- end
83
-
84
- COLLECTION_GROUP_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
85
- "projects/{project}/databases/{database}/collectionGroups/{collection}"
86
- )
87
-
88
- private_constant :COLLECTION_GROUP_PATH_TEMPLATE
89
-
90
- DATABASE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
91
- "projects/{project}/databases/{database}"
92
- )
93
-
94
- private_constant :DATABASE_PATH_TEMPLATE
95
-
96
- FIELD_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
97
- "projects/{project}/databases/{database}/collectionGroups/{collection}/fields/{field}"
98
- )
99
-
100
- private_constant :FIELD_PATH_TEMPLATE
101
-
102
- INDEX_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
103
- "projects/{project}/databases/{database}/collectionGroups/{collection}/indexes/{index}"
104
- )
105
-
106
- private_constant :INDEX_PATH_TEMPLATE
107
-
108
- # Returns a fully-qualified collection_group resource name string.
109
- # @param project [String]
110
- # @param database [String]
111
- # @param collection [String]
112
- # @return [String]
113
- def self.collection_group_path project, database, collection
114
- COLLECTION_GROUP_PATH_TEMPLATE.render(
115
- :"project" => project,
116
- :"database" => database,
117
- :"collection" => collection
118
- )
119
- end
120
-
121
- # Returns a fully-qualified database resource name string.
122
- # @param project [String]
123
- # @param database [String]
124
- # @return [String]
125
- def self.database_path project, database
126
- DATABASE_PATH_TEMPLATE.render(
127
- :"project" => project,
128
- :"database" => database
129
- )
130
- end
131
-
132
- # Returns a fully-qualified field resource name string.
133
- # @param project [String]
134
- # @param database [String]
135
- # @param collection [String]
136
- # @param field [String]
137
- # @return [String]
138
- def self.field_path project, database, collection, field
139
- FIELD_PATH_TEMPLATE.render(
140
- :"project" => project,
141
- :"database" => database,
142
- :"collection" => collection,
143
- :"field" => field
144
- )
145
- end
146
-
147
- # Returns a fully-qualified index resource name string.
148
- # @param project [String]
149
- # @param database [String]
150
- # @param collection [String]
151
- # @param index [String]
152
- # @return [String]
153
- def self.index_path project, database, collection, index
154
- INDEX_PATH_TEMPLATE.render(
155
- :"project" => project,
156
- :"database" => database,
157
- :"collection" => collection,
158
- :"index" => index
159
- )
160
- end
161
-
162
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
163
- # Provides the means for authenticating requests made by the client. This parameter can
164
- # be many types.
165
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
166
- # authenticating requests made by this client.
167
- # A `String` will be treated as the path to the keyfile to be used for the construction of
168
- # credentials for this client.
169
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
170
- # credentials for this client.
171
- # A `GRPC::Core::Channel` will be used to make calls through.
172
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
173
- # should already be composed with a `GRPC::Core::CallCredentials` object.
174
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
175
- # metadata for requests, generally, to give OAuth credentials.
176
- # @param scopes [Array<String>]
177
- # The OAuth scopes for this service. This parameter is ignored if
178
- # an updater_proc is supplied.
179
- # @param client_config [Hash]
180
- # A Hash for call options for each method. See
181
- # Google::Gax#construct_settings for the structure of
182
- # this data. Falls back to the default config if not specified
183
- # or the specified config is missing data points.
184
- # @param timeout [Numeric]
185
- # The default timeout, in seconds, for calls made through this client.
186
- # @param metadata [Hash]
187
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
188
- # @param service_address [String]
189
- # Override for the service hostname, or `nil` to leave as the default.
190
- # @param service_port [Integer]
191
- # Override for the service port, or `nil` to leave as the default.
192
- # @param exception_transformer [Proc]
193
- # An optional proc that intercepts any exceptions raised during an API call to inject
194
- # custom error handling.
195
- def initialize \
196
- credentials: nil,
197
- scopes: ALL_SCOPES,
198
- client_config: {},
199
- timeout: DEFAULT_TIMEOUT,
200
- metadata: nil,
201
- service_address: nil,
202
- service_port: nil,
203
- exception_transformer: nil,
204
- lib_name: nil,
205
- lib_version: ""
206
- # These require statements are intentionally placed here to initialize
207
- # the gRPC module only when it's required.
208
- # See https://github.com/googleapis/toolkit/issues/446
209
- require "google/gax/grpc"
210
- require "google/firestore/admin/v1/firestore_admin_services_pb"
211
-
212
- credentials ||= Google::Cloud::Firestore::Admin::V1::Credentials.default
213
-
214
- @operations_client = OperationsClient.new(
215
- credentials: credentials,
216
- scopes: scopes,
217
- client_config: client_config,
218
- timeout: timeout,
219
- lib_name: lib_name,
220
- service_address: service_address,
221
- service_port: service_port,
222
- lib_version: lib_version,
223
- metadata: metadata,
224
- )
225
-
226
- if credentials.is_a?(String) || credentials.is_a?(Hash)
227
- updater_proc = Google::Cloud::Firestore::Admin::V1::Credentials.new(credentials).updater_proc
228
- end
229
- if credentials.is_a?(GRPC::Core::Channel)
230
- channel = credentials
231
- end
232
- if credentials.is_a?(GRPC::Core::ChannelCredentials)
233
- chan_creds = credentials
234
- end
235
- if credentials.is_a?(Proc)
236
- updater_proc = credentials
237
- end
238
- if credentials.is_a?(Google::Auth::Credentials)
239
- updater_proc = credentials.updater_proc
240
- end
241
-
242
- package_version = Google::Cloud::Firestore::VERSION
243
-
244
- google_api_client = "gl-ruby/#{RUBY_VERSION}"
245
- google_api_client << " #{lib_name}/#{lib_version}" if lib_name
246
- google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
247
- google_api_client << " grpc/#{GRPC::VERSION}"
248
- google_api_client.freeze
249
-
250
- headers = { :"x-goog-api-client" => google_api_client }
251
- if credentials.respond_to?(:quota_project_id) && credentials.quota_project_id
252
- headers[:"x-goog-user-project"] = credentials.quota_project_id
253
- end
254
- headers.merge!(metadata) unless metadata.nil?
255
- client_config_file = Pathname.new(__dir__).join(
256
- "firestore_admin_client_config.json"
257
- )
258
- defaults = client_config_file.open do |f|
259
- Google::Gax.construct_settings(
260
- "google.firestore.admin.v1.FirestoreAdmin",
261
- JSON.parse(f.read),
262
- client_config,
263
- Google::Gax::Grpc::STATUS_CODE_NAMES,
264
- timeout,
265
- page_descriptors: PAGE_DESCRIPTORS,
266
- errors: Google::Gax::Grpc::API_ERRORS,
267
- metadata: headers
268
- )
269
- end
270
-
271
- # Allow overriding the service path/port in subclasses.
272
- service_path = service_address || self.class::SERVICE_ADDRESS
273
- port = service_port || self.class::DEFAULT_SERVICE_PORT
274
- interceptors = self.class::GRPC_INTERCEPTORS
275
- @firestore_admin_stub = Google::Gax::Grpc.create_stub(
276
- service_path,
277
- port,
278
- chan_creds: chan_creds,
279
- channel: channel,
280
- updater_proc: updater_proc,
281
- scopes: scopes,
282
- interceptors: interceptors,
283
- &Google::Firestore::Admin::V1::FirestoreAdmin::Stub.method(:new)
284
- )
285
-
286
- @delete_index = Google::Gax.create_api_call(
287
- @firestore_admin_stub.method(:delete_index),
288
- defaults["delete_index"],
289
- exception_transformer: exception_transformer,
290
- params_extractor: proc do |request|
291
- {'name' => request.name}
292
- end
293
- )
294
- @update_field = Google::Gax.create_api_call(
295
- @firestore_admin_stub.method(:update_field),
296
- defaults["update_field"],
297
- exception_transformer: exception_transformer,
298
- params_extractor: proc do |request|
299
- {'field.name' => request.field.name}
300
- end
301
- )
302
- @create_index = Google::Gax.create_api_call(
303
- @firestore_admin_stub.method(:create_index),
304
- defaults["create_index"],
305
- exception_transformer: exception_transformer,
306
- params_extractor: proc do |request|
307
- {'parent' => request.parent}
308
- end
309
- )
310
- @list_indexes = Google::Gax.create_api_call(
311
- @firestore_admin_stub.method(:list_indexes),
312
- defaults["list_indexes"],
313
- exception_transformer: exception_transformer,
314
- params_extractor: proc do |request|
315
- {'parent' => request.parent}
316
- end
317
- )
318
- @get_index = Google::Gax.create_api_call(
319
- @firestore_admin_stub.method(:get_index),
320
- defaults["get_index"],
321
- exception_transformer: exception_transformer,
322
- params_extractor: proc do |request|
323
- {'name' => request.name}
324
- end
325
- )
326
- @get_field = Google::Gax.create_api_call(
327
- @firestore_admin_stub.method(:get_field),
328
- defaults["get_field"],
329
- exception_transformer: exception_transformer,
330
- params_extractor: proc do |request|
331
- {'name' => request.name}
332
- end
333
- )
334
- @list_fields = Google::Gax.create_api_call(
335
- @firestore_admin_stub.method(:list_fields),
336
- defaults["list_fields"],
337
- exception_transformer: exception_transformer,
338
- params_extractor: proc do |request|
339
- {'parent' => request.parent}
340
- end
341
- )
342
- @export_documents = Google::Gax.create_api_call(
343
- @firestore_admin_stub.method(:export_documents),
344
- defaults["export_documents"],
345
- exception_transformer: exception_transformer,
346
- params_extractor: proc do |request|
347
- {'name' => request.name}
348
- end
349
- )
350
- @import_documents = Google::Gax.create_api_call(
351
- @firestore_admin_stub.method(:import_documents),
352
- defaults["import_documents"],
353
- exception_transformer: exception_transformer,
354
- params_extractor: proc do |request|
355
- {'name' => request.name}
356
- end
357
- )
358
- end
359
-
360
- # Service calls
361
-
362
- # Deletes a composite index.
363
- #
364
- # @param name [String]
365
- # Required. A name of the form
366
- # `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
367
- # @param options [Google::Gax::CallOptions]
368
- # Overrides the default settings for this call, e.g, timeout,
369
- # retries, etc.
370
- # @yield [result, operation] Access the result along with the RPC operation
371
- # @yieldparam result []
372
- # @yieldparam operation [GRPC::ActiveCall::Operation]
373
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
374
- # @example
375
- # require "google/cloud/firestore/admin"
376
- #
377
- # firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
378
- # formatted_name = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.index_path("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]")
379
- # firestore_admin_client.delete_index(formatted_name)
380
-
381
- def delete_index \
382
- name,
383
- options: nil,
384
- &block
385
- req = {
386
- name: name
387
- }.delete_if { |_, v| v.nil? }
388
- req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::DeleteIndexRequest)
389
- @delete_index.call(req, options, &block)
390
- nil
391
- end
392
-
393
- # Updates a field configuration. Currently, field updates apply only to
394
- # single field index configuration. However, calls to
395
- # {Google::Firestore::Admin::V1::FirestoreAdmin::UpdateField FirestoreAdmin::UpdateField} should provide a field mask to avoid
396
- # changing any configuration that the caller isn't aware of. The field mask
397
- # should be specified as: `{ paths: "index_config" }`.
398
- #
399
- # This call returns a {Google::Longrunning::Operation} which may be used to
400
- # track the status of the field update. The metadata for
401
- # the operation will be the type {Google::Firestore::Admin::V1::FieldOperationMetadata FieldOperationMetadata}.
402
- #
403
- # To configure the default field settings for the database, use
404
- # the special `Field` with resource name:
405
- # `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`.
406
- #
407
- # @param field [Google::Firestore::Admin::V1::Field | Hash]
408
- # Required. The field to be updated.
409
- # A hash of the same form as `Google::Firestore::Admin::V1::Field`
410
- # can also be provided.
411
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
412
- # A mask, relative to the field. If specified, only configuration specified
413
- # by this field_mask will be updated in the field.
414
- # A hash of the same form as `Google::Protobuf::FieldMask`
415
- # can also be provided.
416
- # @param options [Google::Gax::CallOptions]
417
- # Overrides the default settings for this call, e.g, timeout,
418
- # retries, etc.
419
- # @return [Google::Gax::Operation]
420
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
421
- # @example
422
- # require "google/cloud/firestore/admin"
423
- #
424
- # firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
425
- #
426
- # # TODO: Initialize `field`:
427
- # field = {}
428
- #
429
- # # Register a callback during the method call.
430
- # operation = firestore_admin_client.update_field(field) do |op|
431
- # raise op.results.message if op.error?
432
- # op_results = op.results
433
- # # Process the results.
434
- #
435
- # metadata = op.metadata
436
- # # Process the metadata.
437
- # end
438
- #
439
- # # Or use the return value to register a callback.
440
- # operation.on_done do |op|
441
- # raise op.results.message if op.error?
442
- # op_results = op.results
443
- # # Process the results.
444
- #
445
- # metadata = op.metadata
446
- # # Process the metadata.
447
- # end
448
- #
449
- # # Manually reload the operation.
450
- # operation.reload!
451
- #
452
- # # Or block until the operation completes, triggering callbacks on
453
- # # completion.
454
- # operation.wait_until_done!
455
-
456
- def update_field \
457
- field,
458
- update_mask: nil,
459
- options: nil
460
- req = {
461
- field: field,
462
- update_mask: update_mask
463
- }.delete_if { |_, v| v.nil? }
464
- req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::UpdateFieldRequest)
465
- operation = Google::Gax::Operation.new(
466
- @update_field.call(req, options),
467
- @operations_client,
468
- Google::Firestore::Admin::V1::Field,
469
- Google::Firestore::Admin::V1::FieldOperationMetadata,
470
- call_options: options
471
- )
472
- operation.on_done { |operation| yield(operation) } if block_given?
473
- operation
474
- end
475
-
476
- # Creates a composite index. This returns a {Google::Longrunning::Operation}
477
- # which may be used to track the status of the creation. The metadata for
478
- # the operation will be the type {Google::Firestore::Admin::V1::IndexOperationMetadata IndexOperationMetadata}.
479
- #
480
- # @param parent [String]
481
- # Required. A parent name of the form
482
- # `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
483
- # @param index [Google::Firestore::Admin::V1::Index | Hash]
484
- # Required. The composite index to create.
485
- # A hash of the same form as `Google::Firestore::Admin::V1::Index`
486
- # can also be provided.
487
- # @param options [Google::Gax::CallOptions]
488
- # Overrides the default settings for this call, e.g, timeout,
489
- # retries, etc.
490
- # @return [Google::Gax::Operation]
491
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
492
- # @example
493
- # require "google/cloud/firestore/admin"
494
- #
495
- # firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
496
- # formatted_parent = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.collection_group_path("[PROJECT]", "[DATABASE]", "[COLLECTION]")
497
- #
498
- # # TODO: Initialize `index`:
499
- # index = {}
500
- #
501
- # # Register a callback during the method call.
502
- # operation = firestore_admin_client.create_index(formatted_parent, index) do |op|
503
- # raise op.results.message if op.error?
504
- # op_results = op.results
505
- # # Process the results.
506
- #
507
- # metadata = op.metadata
508
- # # Process the metadata.
509
- # end
510
- #
511
- # # Or use the return value to register a callback.
512
- # operation.on_done do |op|
513
- # raise op.results.message if op.error?
514
- # op_results = op.results
515
- # # Process the results.
516
- #
517
- # metadata = op.metadata
518
- # # Process the metadata.
519
- # end
520
- #
521
- # # Manually reload the operation.
522
- # operation.reload!
523
- #
524
- # # Or block until the operation completes, triggering callbacks on
525
- # # completion.
526
- # operation.wait_until_done!
527
-
528
- def create_index \
529
- parent,
530
- index,
531
- options: nil
532
- req = {
533
- parent: parent,
534
- index: index
535
- }.delete_if { |_, v| v.nil? }
536
- req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::CreateIndexRequest)
537
- operation = Google::Gax::Operation.new(
538
- @create_index.call(req, options),
539
- @operations_client,
540
- Google::Firestore::Admin::V1::Index,
541
- Google::Firestore::Admin::V1::IndexOperationMetadata,
542
- call_options: options
543
- )
544
- operation.on_done { |operation| yield(operation) } if block_given?
545
- operation
546
- end
547
-
548
- # Lists composite indexes.
549
- #
550
- # @param parent [String]
551
- # Required. A parent name of the form
552
- # `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
553
- # @param filter [String]
554
- # The filter to apply to list results.
555
- # @param page_size [Integer]
556
- # The maximum number of resources contained in the underlying API
557
- # response. If page streaming is performed per-resource, this
558
- # parameter does not affect the return value. If page streaming is
559
- # performed per-page, this determines the maximum number of
560
- # resources in a page.
561
- # @param options [Google::Gax::CallOptions]
562
- # Overrides the default settings for this call, e.g, timeout,
563
- # retries, etc.
564
- # @yield [result, operation] Access the result along with the RPC operation
565
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Firestore::Admin::V1::Index>]
566
- # @yieldparam operation [GRPC::ActiveCall::Operation]
567
- # @return [Google::Gax::PagedEnumerable<Google::Firestore::Admin::V1::Index>]
568
- # An enumerable of Google::Firestore::Admin::V1::Index instances.
569
- # See Google::Gax::PagedEnumerable documentation for other
570
- # operations such as per-page iteration or access to the response
571
- # object.
572
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
573
- # @example
574
- # require "google/cloud/firestore/admin"
575
- #
576
- # firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
577
- # formatted_parent = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.collection_group_path("[PROJECT]", "[DATABASE]", "[COLLECTION]")
578
- #
579
- # # Iterate over all results.
580
- # firestore_admin_client.list_indexes(formatted_parent).each do |element|
581
- # # Process element.
582
- # end
583
- #
584
- # # Or iterate over results one page at a time.
585
- # firestore_admin_client.list_indexes(formatted_parent).each_page do |page|
586
- # # Process each page at a time.
587
- # page.each do |element|
588
- # # Process element.
589
- # end
590
- # end
591
-
592
- def list_indexes \
593
- parent,
594
- filter: nil,
595
- page_size: nil,
596
- options: nil,
597
- &block
598
- req = {
599
- parent: parent,
600
- filter: filter,
601
- page_size: page_size
602
- }.delete_if { |_, v| v.nil? }
603
- req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::ListIndexesRequest)
604
- @list_indexes.call(req, options, &block)
605
- end
606
-
607
- # Gets a composite index.
608
- #
609
- # @param name [String]
610
- # Required. A name of the form
611
- # `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
612
- # @param options [Google::Gax::CallOptions]
613
- # Overrides the default settings for this call, e.g, timeout,
614
- # retries, etc.
615
- # @yield [result, operation] Access the result along with the RPC operation
616
- # @yieldparam result [Google::Firestore::Admin::V1::Index]
617
- # @yieldparam operation [GRPC::ActiveCall::Operation]
618
- # @return [Google::Firestore::Admin::V1::Index]
619
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
620
- # @example
621
- # require "google/cloud/firestore/admin"
622
- #
623
- # firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
624
- # formatted_name = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.index_path("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]")
625
- # response = firestore_admin_client.get_index(formatted_name)
626
-
627
- def get_index \
628
- name,
629
- options: nil,
630
- &block
631
- req = {
632
- name: name
633
- }.delete_if { |_, v| v.nil? }
634
- req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::GetIndexRequest)
635
- @get_index.call(req, options, &block)
636
- end
637
-
638
- # Gets the metadata and configuration for a Field.
639
- #
640
- # @param name [String]
641
- # Required. A name of the form
642
- # `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}`
643
- # @param options [Google::Gax::CallOptions]
644
- # Overrides the default settings for this call, e.g, timeout,
645
- # retries, etc.
646
- # @yield [result, operation] Access the result along with the RPC operation
647
- # @yieldparam result [Google::Firestore::Admin::V1::Field]
648
- # @yieldparam operation [GRPC::ActiveCall::Operation]
649
- # @return [Google::Firestore::Admin::V1::Field]
650
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
651
- # @example
652
- # require "google/cloud/firestore/admin"
653
- #
654
- # firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
655
- # formatted_name = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.field_path("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]")
656
- # response = firestore_admin_client.get_field(formatted_name)
657
-
658
- def get_field \
659
- name,
660
- options: nil,
661
- &block
662
- req = {
663
- name: name
664
- }.delete_if { |_, v| v.nil? }
665
- req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::GetFieldRequest)
666
- @get_field.call(req, options, &block)
667
- end
668
-
669
- # Lists the field configuration and metadata for this database.
670
- #
671
- # Currently, {Google::Firestore::Admin::V1::FirestoreAdmin::ListFields FirestoreAdmin::ListFields} only supports listing fields
672
- # that have been explicitly overridden. To issue this query, call
673
- # {Google::Firestore::Admin::V1::FirestoreAdmin::ListFields FirestoreAdmin::ListFields} with the filter set to
674
- # `indexConfig.usesAncestorConfig:false`.
675
- #
676
- # @param parent [String]
677
- # Required. A parent name of the form
678
- # `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
679
- # @param filter [String]
680
- # The filter to apply to list results. Currently,
681
- # {Google::Firestore::Admin::V1::FirestoreAdmin::ListFields FirestoreAdmin::ListFields} only supports listing fields
682
- # that have been explicitly overridden. To issue this query, call
683
- # {Google::Firestore::Admin::V1::FirestoreAdmin::ListFields FirestoreAdmin::ListFields} with the filter set to
684
- # `indexConfig.usesAncestorConfig:false`.
685
- # @param page_size [Integer]
686
- # The maximum number of resources contained in the underlying API
687
- # response. If page streaming is performed per-resource, this
688
- # parameter does not affect the return value. If page streaming is
689
- # performed per-page, this determines the maximum number of
690
- # resources in a page.
691
- # @param options [Google::Gax::CallOptions]
692
- # Overrides the default settings for this call, e.g, timeout,
693
- # retries, etc.
694
- # @yield [result, operation] Access the result along with the RPC operation
695
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Firestore::Admin::V1::Field>]
696
- # @yieldparam operation [GRPC::ActiveCall::Operation]
697
- # @return [Google::Gax::PagedEnumerable<Google::Firestore::Admin::V1::Field>]
698
- # An enumerable of Google::Firestore::Admin::V1::Field instances.
699
- # See Google::Gax::PagedEnumerable documentation for other
700
- # operations such as per-page iteration or access to the response
701
- # object.
702
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
703
- # @example
704
- # require "google/cloud/firestore/admin"
705
- #
706
- # firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
707
- # formatted_parent = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.collection_group_path("[PROJECT]", "[DATABASE]", "[COLLECTION]")
708
- #
709
- # # Iterate over all results.
710
- # firestore_admin_client.list_fields(formatted_parent).each do |element|
711
- # # Process element.
712
- # end
713
- #
714
- # # Or iterate over results one page at a time.
715
- # firestore_admin_client.list_fields(formatted_parent).each_page do |page|
716
- # # Process each page at a time.
717
- # page.each do |element|
718
- # # Process element.
719
- # end
720
- # end
721
-
722
- def list_fields \
723
- parent,
724
- filter: nil,
725
- page_size: nil,
726
- options: nil,
727
- &block
728
- req = {
729
- parent: parent,
730
- filter: filter,
731
- page_size: page_size
732
- }.delete_if { |_, v| v.nil? }
733
- req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::ListFieldsRequest)
734
- @list_fields.call(req, options, &block)
735
- end
736
-
737
- # Exports a copy of all or a subset of documents from Google Cloud Firestore
738
- # to another storage system, such as Google Cloud Storage. Recent updates to
739
- # documents may not be reflected in the export. The export occurs in the
740
- # background and its progress can be monitored and managed via the
741
- # Operation resource that is created. The output of an export may only be
742
- # used once the associated operation is done. If an export operation is
743
- # cancelled before completion it may leave partial data behind in Google
744
- # Cloud Storage.
745
- #
746
- # @param name [String]
747
- # Required. Database to export. Should be of the form:
748
- # `projects/{project_id}/databases/{database_id}`.
749
- # @param collection_ids [Array<String>]
750
- # Which collection ids to export. Unspecified means all collections.
751
- # @param output_uri_prefix [String]
752
- # The output URI. Currently only supports Google Cloud Storage URIs of the
753
- # form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name
754
- # of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional
755
- # Google Cloud Storage namespace path. When
756
- # choosing a name, be sure to consider Google Cloud Storage naming
757
- # guidelines: https://cloud.google.com/storage/docs/naming.
758
- # If the URI is a bucket (without a namespace path), a prefix will be
759
- # generated based on the start time.
760
- # @param options [Google::Gax::CallOptions]
761
- # Overrides the default settings for this call, e.g, timeout,
762
- # retries, etc.
763
- # @return [Google::Gax::Operation]
764
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
765
- # @example
766
- # require "google/cloud/firestore/admin"
767
- #
768
- # firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
769
- # formatted_name = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.database_path("[PROJECT]", "[DATABASE]")
770
- #
771
- # # Register a callback during the method call.
772
- # operation = firestore_admin_client.export_documents(formatted_name) do |op|
773
- # raise op.results.message if op.error?
774
- # op_results = op.results
775
- # # Process the results.
776
- #
777
- # metadata = op.metadata
778
- # # Process the metadata.
779
- # end
780
- #
781
- # # Or use the return value to register a callback.
782
- # operation.on_done do |op|
783
- # raise op.results.message if op.error?
784
- # op_results = op.results
785
- # # Process the results.
786
- #
787
- # metadata = op.metadata
788
- # # Process the metadata.
789
- # end
790
- #
791
- # # Manually reload the operation.
792
- # operation.reload!
793
- #
794
- # # Or block until the operation completes, triggering callbacks on
795
- # # completion.
796
- # operation.wait_until_done!
797
-
798
- def export_documents \
799
- name,
800
- collection_ids: nil,
801
- output_uri_prefix: nil,
802
- options: nil
803
- req = {
804
- name: name,
805
- collection_ids: collection_ids,
806
- output_uri_prefix: output_uri_prefix
807
- }.delete_if { |_, v| v.nil? }
808
- req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::ExportDocumentsRequest)
809
- operation = Google::Gax::Operation.new(
810
- @export_documents.call(req, options),
811
- @operations_client,
812
- Google::Firestore::Admin::V1::ExportDocumentsResponse,
813
- Google::Firestore::Admin::V1::ExportDocumentsMetadata,
814
- call_options: options
815
- )
816
- operation.on_done { |operation| yield(operation) } if block_given?
817
- operation
818
- end
819
-
820
- # Imports documents into Google Cloud Firestore. Existing documents with the
821
- # same name are overwritten. The import occurs in the background and its
822
- # progress can be monitored and managed via the Operation resource that is
823
- # created. If an ImportDocuments operation is cancelled, it is possible
824
- # that a subset of the data has already been imported to Cloud Firestore.
825
- #
826
- # @param name [String]
827
- # Required. Database to import into. Should be of the form:
828
- # `projects/{project_id}/databases/{database_id}`.
829
- # @param collection_ids [Array<String>]
830
- # Which collection ids to import. Unspecified means all collections included
831
- # in the import.
832
- # @param input_uri_prefix [String]
833
- # Location of the exported files.
834
- # This must match the output_uri_prefix of an ExportDocumentsResponse from
835
- # an export that has completed successfully.
836
- # See:
837
- # {Google::Firestore::Admin::V1::ExportDocumentsResponse#output_uri_prefix}.
838
- # @param options [Google::Gax::CallOptions]
839
- # Overrides the default settings for this call, e.g, timeout,
840
- # retries, etc.
841
- # @return [Google::Gax::Operation]
842
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
843
- # @example
844
- # require "google/cloud/firestore/admin"
845
- #
846
- # firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
847
- # formatted_name = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.database_path("[PROJECT]", "[DATABASE]")
848
- #
849
- # # Register a callback during the method call.
850
- # operation = firestore_admin_client.import_documents(formatted_name) do |op|
851
- # raise op.results.message if op.error?
852
- # op_results = op.results
853
- # # Process the results.
854
- #
855
- # metadata = op.metadata
856
- # # Process the metadata.
857
- # end
858
- #
859
- # # Or use the return value to register a callback.
860
- # operation.on_done do |op|
861
- # raise op.results.message if op.error?
862
- # op_results = op.results
863
- # # Process the results.
864
- #
865
- # metadata = op.metadata
866
- # # Process the metadata.
867
- # end
868
- #
869
- # # Manually reload the operation.
870
- # operation.reload!
871
- #
872
- # # Or block until the operation completes, triggering callbacks on
873
- # # completion.
874
- # operation.wait_until_done!
875
-
876
- def import_documents \
877
- name,
878
- collection_ids: nil,
879
- input_uri_prefix: nil,
880
- options: nil
881
- req = {
882
- name: name,
883
- collection_ids: collection_ids,
884
- input_uri_prefix: input_uri_prefix
885
- }.delete_if { |_, v| v.nil? }
886
- req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::ImportDocumentsRequest)
887
- operation = Google::Gax::Operation.new(
888
- @import_documents.call(req, options),
889
- @operations_client,
890
- Google::Protobuf::Empty,
891
- Google::Firestore::Admin::V1::ImportDocumentsMetadata,
892
- call_options: options
893
- )
894
- operation.on_done { |operation| yield(operation) } if block_given?
895
- operation
896
- end
897
- end
898
- end
899
- end
900
- end
901
- end
902
- end