google-cloud-firestore 2.7.2 → 2.15.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 (30) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +8 -26
  3. data/CHANGELOG.md +69 -0
  4. data/LOGGING.md +1 -1
  5. data/lib/google/cloud/firestore/aggregate_query.rb +285 -0
  6. data/lib/google/cloud/firestore/aggregate_query_snapshot.rb +145 -0
  7. data/lib/google/cloud/firestore/bulk_commit_batch.rb +73 -0
  8. data/lib/google/cloud/firestore/bulk_writer.rb +558 -0
  9. data/lib/google/cloud/firestore/bulk_writer_exception.rb +40 -0
  10. data/lib/google/cloud/firestore/bulk_writer_operation.rb +126 -0
  11. data/lib/google/cloud/firestore/bulk_writer_scheduler.rb +164 -0
  12. data/lib/google/cloud/firestore/client.rb +161 -10
  13. data/lib/google/cloud/firestore/collection_group.rb +20 -4
  14. data/lib/google/cloud/firestore/collection_reference.rb +17 -2
  15. data/lib/google/cloud/firestore/collection_reference_list.rb +4 -3
  16. data/lib/google/cloud/firestore/convert.rb +6 -7
  17. data/lib/google/cloud/firestore/document_reference/list.rb +5 -3
  18. data/lib/google/cloud/firestore/document_reference.rb +20 -3
  19. data/lib/google/cloud/firestore/document_snapshot.rb +1 -1
  20. data/lib/google/cloud/firestore/errors.rb +60 -0
  21. data/lib/google/cloud/firestore/filter.rb +326 -0
  22. data/lib/google/cloud/firestore/promise/future.rb +97 -0
  23. data/lib/google/cloud/firestore/query.rb +112 -89
  24. data/lib/google/cloud/firestore/rate_limiter.rb +80 -0
  25. data/lib/google/cloud/firestore/service.rb +74 -23
  26. data/lib/google/cloud/firestore/transaction.rb +57 -4
  27. data/lib/google/cloud/firestore/version.rb +1 -1
  28. data/lib/google/cloud/firestore.rb +17 -7
  29. data/lib/google-cloud-firestore.rb +45 -8
  30. metadata +17 -146
@@ -59,6 +59,10 @@ module Google
59
59
  # If the param is nil, uses the default endpoint.
60
60
  # @param [String] emulator_host Firestore emulator host. Optional.
61
61
  # If the param is nil, uses the value of the `emulator_host` config.
62
+ # @param [String] database_id Identifier for a Firestore database. If not
63
+ # present, the default database of the project is used.
64
+ # @param [:grpc,:rest] transport Which transport to use to communicate
65
+ # with the server. Defaults to `:grpc`.
62
66
  # @param [String] project Alias for the `project_id` argument. Deprecated.
63
67
  # @param [String] keyfile Alias for the `credentials` argument.
64
68
  # Deprecated.
@@ -76,23 +80,28 @@ module Google
76
80
  timeout: nil,
77
81
  endpoint: nil,
78
82
  emulator_host: nil,
83
+ database_id: nil,
84
+ transport: nil,
79
85
  project: nil,
80
86
  keyfile: nil
81
- project_id ||= (project || default_project_id)
82
- scope ||= configure.scope
83
- timeout ||= configure.timeout
84
- endpoint ||= configure.endpoint
87
+ project_id ||= project || default_project_id
88
+ scope ||= configure.scope
89
+ timeout ||= configure.timeout
90
+ endpoint ||= configure.endpoint
85
91
  emulator_host ||= configure.emulator_host
92
+ database_id ||= configure.database_id
93
+ transport ||= configure.transport
86
94
 
87
95
  if emulator_host
88
96
  project_id = project_id.to_s
89
97
  raise ArgumentError, "project_id is missing" if project_id.empty?
90
98
 
91
- service = Firestore::Service.new project_id, :this_channel_is_insecure, host: emulator_host, timeout: timeout
99
+ service = Firestore::Service.new project_id, :this_channel_is_insecure, host: emulator_host,
100
+ timeout: timeout, database: database_id, transport: transport
92
101
  return Firestore::Client.new service
93
102
  end
94
103
 
95
- credentials ||= (keyfile || default_credentials(scope: scope))
104
+ credentials ||= keyfile || default_credentials(scope: scope)
96
105
  unless credentials.is_a? Google::Auth::Credentials
97
106
  credentials = Firestore::Credentials.new credentials, scope: scope
98
107
  end
@@ -103,7 +112,8 @@ module Google
103
112
  project_id = project_id.to_s
104
113
  raise ArgumentError, "project_id is missing" if project_id.empty?
105
114
 
106
- service = Firestore::Service.new project_id, credentials, host: endpoint, timeout: timeout
115
+ service = Firestore::Service.new project_id, credentials, host: endpoint,
116
+ timeout: timeout, database: database_id, transport: transport
107
117
  Firestore::Client.new service
108
118
  end
109
119
 
@@ -42,6 +42,10 @@ module Google
42
42
  #
43
43
  # * `https://www.googleapis.com/auth/datastore`
44
44
  # @param [Integer] timeout Default timeout to use in requests. Optional.
45
+ # @param [String] database_id Identifier for a Firestore database. If not
46
+ # present, the default database of the project is used.
47
+ # @param [:grpc,:rest] transport Which transport to use to communicate
48
+ # with the server. Defaults to `:grpc`.
45
49
  #
46
50
  # @return [Google::Cloud::Firestore::Client]
47
51
  #
@@ -58,8 +62,24 @@ module Google
58
62
  # platform_scope = "https://www.googleapis.com/auth/cloud-platform"
59
63
  # firestore = gcloud.firestore scope: platform_scope
60
64
  #
61
- def firestore scope: nil, timeout: nil
62
- Google::Cloud.firestore @project, @keyfile, scope: scope, timeout: (timeout || @timeout)
65
+ # @example The default database can be overridden with the `database_id` option:
66
+ # require "google/cloud"
67
+ #
68
+ # gcloud = Google::Cloud.new
69
+ # database_id = "my-todo-database"
70
+ # firestore = gcloud.firestore database_id: database_id
71
+ #
72
+ def firestore scope: nil,
73
+ timeout: nil,
74
+ database_id: nil,
75
+ transport: nil
76
+ transport ||= Google::Cloud.configure.firestore.transport
77
+ timeout ||= @timeout
78
+ Google::Cloud.firestore @project, @keyfile,
79
+ scope: scope,
80
+ timeout: timeout,
81
+ database_id: database_id,
82
+ transport: transport
63
83
  end
64
84
 
65
85
  ##
@@ -83,6 +103,10 @@ module Google
83
103
  #
84
104
  # * `https://www.googleapis.com/auth/datastore`
85
105
  # @param [Integer] timeout Default timeout to use in requests. Optional.
106
+ # @param [String] database_id Identifier for a Firestore database. If not
107
+ # present, the default database of the project is used.
108
+ # @param [:grpc,:rest] transport Which transport to use to communicate
109
+ # with the server. Defaults to `:grpc`.
86
110
  #
87
111
  # @return [Google::Cloud::Firestore::Client]
88
112
  #
@@ -91,16 +115,26 @@ module Google
91
115
  #
92
116
  # firestore = Google::Cloud.firestore
93
117
  #
94
- def self.firestore project_id = nil, credentials = nil, scope: nil, timeout: nil
118
+ def self.firestore project_id = nil,
119
+ credentials = nil,
120
+ scope: nil,
121
+ timeout: nil,
122
+ database_id: nil,
123
+ transport: nil
95
124
  require "google/cloud/firestore"
96
- Google::Cloud::Firestore.new project_id: project_id,
125
+ transport ||= Google::Cloud.configure.firestore.transport
126
+ Google::Cloud::Firestore.new project_id: project_id,
97
127
  credentials: credentials,
98
- scope: scope,
99
- timeout: timeout
128
+ scope: scope,
129
+ timeout: timeout,
130
+ database_id: database_id,
131
+ transport: transport
100
132
  end
101
133
  end
102
134
  end
103
135
 
136
+ # rubocop:disable Metrics/BlockLength
137
+
104
138
  # Set the default firestore configuration
105
139
  Google::Cloud.configure.add_config! :firestore do |config|
106
140
  default_project = Google::Cloud::Config.deferred do
@@ -116,8 +150,7 @@ Google::Cloud.configure.add_config! :firestore do |config|
116
150
  ENV["FIRESTORE_EMULATOR_HOST"]
117
151
  end
118
152
  default_scopes = [
119
- "https://www.googleapis.com/auth/cloud-platform",
120
- "https://www.googleapis.com/auth/datastore"
153
+ "https://www.googleapis.com/auth/cloud-platform", "https://www.googleapis.com/auth/datastore"
121
154
  ]
122
155
 
123
156
  config.add_field! :project_id, default_project, match: String, allow_nil: true
@@ -129,4 +162,8 @@ Google::Cloud.configure.add_config! :firestore do |config|
129
162
  config.add_field! :timeout, nil, match: Integer
130
163
  config.add_field! :emulator_host, default_emulator, match: String, allow_nil: true
131
164
  config.add_field! :endpoint, "firestore.googleapis.com", match: String
165
+ config.add_field! :database_id, "(default)", match: String
166
+ config.add_field! :transport, :grpc, match: Symbol
132
167
  end
168
+
169
+ # rubocop:enable Metrics/BlockLength
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-firestore
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.2
4
+ version: 2.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Google Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-24 00:00:00.000000000 Z
11
+ date: 2024-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-cloud-core
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.0'
33
+ version: '0.10'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.0'
40
+ version: '0.10'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: concurrent-ruby
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,146 +66,6 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.4.2
69
- - !ruby/object:Gem::Dependency
70
- name: google-style
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 1.26.1
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 1.26.1
83
- - !ruby/object:Gem::Dependency
84
- name: minitest
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '5.16'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '5.16'
97
- - !ruby/object:Gem::Dependency
98
- name: minitest-autotest
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '1.0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '1.0'
111
- - !ruby/object:Gem::Dependency
112
- name: minitest-focus
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '1.1'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '1.1'
125
- - !ruby/object:Gem::Dependency
126
- name: minitest-rg
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '5.2'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '5.2'
139
- - !ruby/object:Gem::Dependency
140
- name: autotest-suffix
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: '1.1'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '1.1'
153
- - !ruby/object:Gem::Dependency
154
- name: redcarpet
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - "~>"
158
- - !ruby/object:Gem::Version
159
- version: '3.0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - "~>"
165
- - !ruby/object:Gem::Version
166
- version: '3.0'
167
- - !ruby/object:Gem::Dependency
168
- name: simplecov
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - "~>"
172
- - !ruby/object:Gem::Version
173
- version: '0.9'
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - "~>"
179
- - !ruby/object:Gem::Version
180
- version: '0.9'
181
- - !ruby/object:Gem::Dependency
182
- name: yard
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - "~>"
186
- - !ruby/object:Gem::Version
187
- version: '0.9'
188
- type: :development
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - "~>"
193
- - !ruby/object:Gem::Version
194
- version: '0.9'
195
- - !ruby/object:Gem::Dependency
196
- name: yard-doctest
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - "~>"
200
- - !ruby/object:Gem::Version
201
- version: 0.1.13
202
- type: :development
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - "~>"
207
- - !ruby/object:Gem::Version
208
- version: 0.1.13
209
69
  description: google-cloud-firestore is the official library for Google Cloud Firestore
210
70
  API.
211
71
  email: googleapis-packages@google.com
@@ -225,7 +85,14 @@ files:
225
85
  - TROUBLESHOOTING.md
226
86
  - lib/google-cloud-firestore.rb
227
87
  - lib/google/cloud/firestore.rb
88
+ - lib/google/cloud/firestore/aggregate_query.rb
89
+ - lib/google/cloud/firestore/aggregate_query_snapshot.rb
228
90
  - lib/google/cloud/firestore/batch.rb
91
+ - lib/google/cloud/firestore/bulk_commit_batch.rb
92
+ - lib/google/cloud/firestore/bulk_writer.rb
93
+ - lib/google/cloud/firestore/bulk_writer_exception.rb
94
+ - lib/google/cloud/firestore/bulk_writer_operation.rb
95
+ - lib/google/cloud/firestore/bulk_writer_scheduler.rb
229
96
  - lib/google/cloud/firestore/client.rb
230
97
  - lib/google/cloud/firestore/collection_group.rb
231
98
  - lib/google/cloud/firestore/collection_reference.rb
@@ -238,13 +105,17 @@ files:
238
105
  - lib/google/cloud/firestore/document_reference.rb
239
106
  - lib/google/cloud/firestore/document_reference/list.rb
240
107
  - lib/google/cloud/firestore/document_snapshot.rb
108
+ - lib/google/cloud/firestore/errors.rb
241
109
  - lib/google/cloud/firestore/field_path.rb
242
110
  - lib/google/cloud/firestore/field_value.rb
111
+ - lib/google/cloud/firestore/filter.rb
243
112
  - lib/google/cloud/firestore/generate.rb
113
+ - lib/google/cloud/firestore/promise/future.rb
244
114
  - lib/google/cloud/firestore/query.rb
245
115
  - lib/google/cloud/firestore/query_listener.rb
246
116
  - lib/google/cloud/firestore/query_partition.rb
247
117
  - lib/google/cloud/firestore/query_snapshot.rb
118
+ - lib/google/cloud/firestore/rate_limiter.rb
248
119
  - lib/google/cloud/firestore/resource_path.rb
249
120
  - lib/google/cloud/firestore/service.rb
250
121
  - lib/google/cloud/firestore/transaction.rb
@@ -265,14 +136,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
265
136
  requirements:
266
137
  - - ">="
267
138
  - !ruby/object:Gem::Version
268
- version: '2.6'
139
+ version: '2.7'
269
140
  required_rubygems_version: !ruby/object:Gem::Requirement
270
141
  requirements:
271
142
  - - ">="
272
143
  - !ruby/object:Gem::Version
273
144
  version: '0'
274
145
  requirements: []
275
- rubygems_version: 3.3.14
146
+ rubygems_version: 3.5.6
276
147
  signing_key:
277
148
  specification_version: 4
278
149
  summary: API Client library for Google Cloud Firestore API