google-cloud-firestore-v1 0.7.1 → 0.8.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7922ef0b53adb9cf8c05dea972dc77df76ca049be8d888ebb3070f86520eeba
4
- data.tar.gz: aafccc0aa33cc527e926d2b16696bb2f8d24551e8871d7d604873646d2bd060d
3
+ metadata.gz: dcc0798a8aa1b6a70669958d01f1353dff7e9d002ded6fc42a27ec538d92e597
4
+ data.tar.gz: 5e35f28c24d813ad220148bfe15ba385359440563dedb5b2342a2d262add911c
5
5
  SHA512:
6
- metadata.gz: ae9b1fb54e5792c92296df31b1e1184e2f83a390761ee4f5b6476984e95a2c1c19141e097cefc778c6ab0169bbd3e02ffa89f93f85793f047a65bad7e17d21bc
7
- data.tar.gz: f37cc1e8425e89cfac0569fbf52146ff9e8b1ef36d778ca439a14ba13c564bd2de7886b975cf629de4cd8df52ab3cb847138404aefc5ff7e59afaa4599665943
6
+ metadata.gz: 237cc0f52525a3c60eb4e0783d27c461cc2b21d02359d6e19eccdec1ce70d0dd4aa940fdcc1ae26f71191171c8e7b6a75761bf5402f44bf0aafc6f06df18965b
7
+ data.tar.gz: 6d75b35dc3929b94ea27cbb684f630c7b7b6ff9a569a349688bf25505f4a9d8e54a1ff8836a25d62bb25f3b10c376cd0aede9bb657a854942c9155b0061a59d0
data/AUTHENTICATION.md CHANGED
@@ -114,7 +114,7 @@ credentials are discovered.
114
114
  To configure your system for this, simply:
115
115
 
116
116
  1. [Download and install the Cloud SDK](https://cloud.google.com/sdk)
117
- 2. Authenticate using OAuth 2.0 `$ gcloud auth login`
117
+ 2. Authenticate using OAuth 2.0 `$ gcloud auth application-default login`
118
118
  3. Write code as if already authenticated.
119
119
 
120
120
  **NOTE:** This is _not_ recommended for running in production. The Cloud SDK
@@ -18,6 +18,7 @@
18
18
 
19
19
  require "google/cloud/errors"
20
20
  require "google/firestore/v1/firestore_pb"
21
+ require "google/cloud/location"
21
22
 
22
23
  module Google
23
24
  module Cloud
@@ -114,6 +115,11 @@ module Google
114
115
  initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4]
115
116
  }
116
117
 
118
+ default_config.rpcs.run_aggregation_query.timeout = 300.0
119
+ default_config.rpcs.run_aggregation_query.retry_policy = {
120
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4]
121
+ }
122
+
117
123
  default_config.rpcs.partition_query.timeout = 300.0
118
124
  default_config.rpcs.partition_query.retry_policy = {
119
125
  initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4]
@@ -210,6 +216,12 @@ module Google
210
216
  @quota_project_id = @config.quota_project
211
217
  @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
212
218
 
219
+ @location_client = Google::Cloud::Location::Locations::Client.new do |config|
220
+ config.credentials = credentials
221
+ config.quota_project = @quota_project_id
222
+ config.endpoint = @config.endpoint
223
+ end
224
+
213
225
  @firestore_stub = ::Gapic::ServiceStub.new(
214
226
  ::Google::Cloud::Firestore::V1::Firestore::Stub,
215
227
  credentials: credentials,
@@ -219,6 +231,13 @@ module Google
219
231
  )
220
232
  end
221
233
 
234
+ ##
235
+ # Get the associated client for mix-in of the Locations.
236
+ #
237
+ # @return [Google::Cloud::Location::Locations::Client]
238
+ #
239
+ attr_reader :location_client
240
+
222
241
  # Service calls
223
242
 
224
243
  ##
@@ -1123,6 +1142,127 @@ module Google
1123
1142
  raise ::Google::Cloud::Error.from_error(e)
1124
1143
  end
1125
1144
 
1145
+ ##
1146
+ # Runs an aggregation query.
1147
+ #
1148
+ # Rather than producing {::Google::Cloud::Firestore::V1::Document Document} results like {::Google::Cloud::Firestore::V1::Firestore::Client#run_query Firestore.RunQuery},
1149
+ # this API allows running an aggregation to produce a series of
1150
+ # {::Google::Cloud::Firestore::V1::AggregationResult AggregationResult} server-side.
1151
+ #
1152
+ # High-Level Example:
1153
+ #
1154
+ # ```
1155
+ # -- Return the number of documents in table given a filter.
1156
+ # SELECT COUNT(*) FROM ( SELECT * FROM k where a = true );
1157
+ # ```
1158
+ #
1159
+ # @overload run_aggregation_query(request, options = nil)
1160
+ # Pass arguments to `run_aggregation_query` via a request object, either of type
1161
+ # {::Google::Cloud::Firestore::V1::RunAggregationQueryRequest} or an equivalent Hash.
1162
+ #
1163
+ # @param request [::Google::Cloud::Firestore::V1::RunAggregationQueryRequest, ::Hash]
1164
+ # A request object representing the call parameters. Required. To specify no
1165
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1166
+ # @param options [::Gapic::CallOptions, ::Hash]
1167
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1168
+ #
1169
+ # @overload run_aggregation_query(parent: nil, structured_aggregation_query: nil, transaction: nil, new_transaction: nil, read_time: nil)
1170
+ # Pass arguments to `run_aggregation_query` via keyword arguments. Note that at
1171
+ # least one keyword argument is required. To specify no parameters, or to keep all
1172
+ # the default parameter values, pass an empty Hash as a request object (see above).
1173
+ #
1174
+ # @param parent [::String]
1175
+ # Required. The parent resource name. In the format:
1176
+ # `projects/{project_id}/databases/{database_id}/documents` or
1177
+ # `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
1178
+ # For example:
1179
+ # `projects/my-project/databases/my-database/documents` or
1180
+ # `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
1181
+ # @param structured_aggregation_query [::Google::Cloud::Firestore::V1::StructuredAggregationQuery, ::Hash]
1182
+ # An aggregation query.
1183
+ # @param transaction [::String]
1184
+ # Run the aggregation within an already active transaction.
1185
+ #
1186
+ # The value here is the opaque transaction ID to execute the query in.
1187
+ # @param new_transaction [::Google::Cloud::Firestore::V1::TransactionOptions, ::Hash]
1188
+ # Starts a new transaction as part of the query, defaulting to read-only.
1189
+ #
1190
+ # The new transaction ID will be returned as the first response in the
1191
+ # stream.
1192
+ # @param read_time [::Google::Protobuf::Timestamp, ::Hash]
1193
+ # Executes the query at the given timestamp.
1194
+ #
1195
+ # Requires:
1196
+ #
1197
+ # * Cannot be more than 270 seconds in the past.
1198
+ #
1199
+ # @yield [response, operation] Access the result along with the RPC operation
1200
+ # @yieldparam response [::Enumerable<::Google::Cloud::Firestore::V1::RunAggregationQueryResponse>]
1201
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1202
+ #
1203
+ # @return [::Enumerable<::Google::Cloud::Firestore::V1::RunAggregationQueryResponse>]
1204
+ #
1205
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1206
+ #
1207
+ # @example Basic example
1208
+ # require "google/cloud/firestore/v1"
1209
+ #
1210
+ # # Create a client object. The client can be reused for multiple calls.
1211
+ # client = Google::Cloud::Firestore::V1::Firestore::Client.new
1212
+ #
1213
+ # # Create a request. To set request fields, pass in keyword arguments.
1214
+ # request = Google::Cloud::Firestore::V1::RunAggregationQueryRequest.new
1215
+ #
1216
+ # # Call the run_aggregation_query method.
1217
+ # result = client.run_aggregation_query request
1218
+ #
1219
+ # # The returned object is a streamed enumerable yielding elements of
1220
+ # # type ::Google::Cloud::Firestore::V1::RunAggregationQueryResponse.
1221
+ # result.each do |response|
1222
+ # p response
1223
+ # end
1224
+ #
1225
+ def run_aggregation_query request, options = nil
1226
+ raise ::ArgumentError, "request must be provided" if request.nil?
1227
+
1228
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::RunAggregationQueryRequest
1229
+
1230
+ # Converts hash and nil to an options object
1231
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1232
+
1233
+ # Customize the options with defaults
1234
+ metadata = @config.rpcs.run_aggregation_query.metadata.to_h
1235
+
1236
+ # Set x-goog-api-client and x-goog-user-project headers
1237
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1238
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1239
+ gapic_version: ::Google::Cloud::Firestore::V1::VERSION
1240
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1241
+
1242
+ header_params = {}
1243
+ if request.parent
1244
+ header_params["parent"] = request.parent
1245
+ end
1246
+
1247
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1248
+ metadata[:"x-goog-request-params"] ||= request_params_header
1249
+
1250
+ options.apply_defaults timeout: @config.rpcs.run_aggregation_query.timeout,
1251
+ metadata: metadata,
1252
+ retry_policy: @config.rpcs.run_aggregation_query.retry_policy
1253
+
1254
+ options.apply_defaults timeout: @config.timeout,
1255
+ metadata: @config.metadata,
1256
+ retry_policy: @config.retry_policy
1257
+
1258
+ @firestore_stub.call_rpc :run_aggregation_query, request, options: options do |response, operation|
1259
+ yield response, operation if block_given?
1260
+ return response
1261
+ end
1262
+ rescue ::GRPC::BadStatus => e
1263
+ raise ::Google::Cloud::Error.from_error(e)
1264
+ end
1265
+
1126
1266
  ##
1127
1267
  # Partitions a query by returning partition cursors that can be used to run
1128
1268
  # the query in parallel. The returned partition cursors are split points that
@@ -1897,6 +2037,11 @@ module Google
1897
2037
  #
1898
2038
  attr_reader :run_query
1899
2039
  ##
2040
+ # RPC-specific configuration for `run_aggregation_query`
2041
+ # @return [::Gapic::Config::Method]
2042
+ #
2043
+ attr_reader :run_aggregation_query
2044
+ ##
1900
2045
  # RPC-specific configuration for `partition_query`
1901
2046
  # @return [::Gapic::Config::Method]
1902
2047
  #
@@ -1947,6 +2092,8 @@ module Google
1947
2092
  @rollback = ::Gapic::Config::Method.new rollback_config
1948
2093
  run_query_config = parent_rpcs.run_query if parent_rpcs.respond_to? :run_query
1949
2094
  @run_query = ::Gapic::Config::Method.new run_query_config
2095
+ run_aggregation_query_config = parent_rpcs.run_aggregation_query if parent_rpcs.respond_to? :run_aggregation_query
2096
+ @run_aggregation_query = ::Gapic::Config::Method.new run_aggregation_query_config
1950
2097
  partition_query_config = parent_rpcs.partition_query if parent_rpcs.respond_to? :partition_query
1951
2098
  @partition_query = ::Gapic::Config::Method.new partition_query_config
1952
2099
  write_config = parent_rpcs.write if parent_rpcs.respond_to? :write
@@ -21,7 +21,7 @@ module Google
21
21
  module Cloud
22
22
  module Firestore
23
23
  module V1
24
- VERSION = "0.7.1"
24
+ VERSION = "0.8.0"
25
25
  end
26
26
  end
27
27
  end
@@ -0,0 +1,24 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: google/firestore/v1/aggregation_result.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'google/firestore/v1/document_pb'
7
+
8
+ Google::Protobuf::DescriptorPool.generated_pool.build do
9
+ add_file("google/firestore/v1/aggregation_result.proto", :syntax => :proto3) do
10
+ add_message "google.firestore.v1.AggregationResult" do
11
+ map :aggregate_fields, :string, :message, 2, "google.firestore.v1.Value"
12
+ end
13
+ end
14
+ end
15
+
16
+ module Google
17
+ module Cloud
18
+ module Firestore
19
+ module V1
20
+ AggregationResult = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.firestore.v1.AggregationResult").msgclass
21
+ end
22
+ end
23
+ end
24
+ end
@@ -6,6 +6,7 @@ require 'google/protobuf'
6
6
  require 'google/api/annotations_pb'
7
7
  require 'google/api/client_pb'
8
8
  require 'google/api/field_behavior_pb'
9
+ require 'google/firestore/v1/aggregation_result_pb'
9
10
  require 'google/firestore/v1/common_pb'
10
11
  require 'google/firestore/v1/document_pb'
11
12
  require 'google/firestore/v1/query_pb'
@@ -116,6 +117,22 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
116
117
  optional :done, :bool, 6
117
118
  end
118
119
  end
120
+ add_message "google.firestore.v1.RunAggregationQueryRequest" do
121
+ optional :parent, :string, 1
122
+ oneof :query_type do
123
+ optional :structured_aggregation_query, :message, 2, "google.firestore.v1.StructuredAggregationQuery"
124
+ end
125
+ oneof :consistency_selector do
126
+ optional :transaction, :bytes, 4
127
+ optional :new_transaction, :message, 5, "google.firestore.v1.TransactionOptions"
128
+ optional :read_time, :message, 6, "google.protobuf.Timestamp"
129
+ end
130
+ end
131
+ add_message "google.firestore.v1.RunAggregationQueryResponse" do
132
+ optional :result, :message, 1, "google.firestore.v1.AggregationResult"
133
+ optional :transaction, :bytes, 2
134
+ optional :read_time, :message, 3, "google.protobuf.Timestamp"
135
+ end
119
136
  add_message "google.firestore.v1.PartitionQueryRequest" do
120
137
  optional :parent, :string, 1
121
138
  optional :partition_count, :int64, 3
@@ -240,6 +257,8 @@ module Google
240
257
  RollbackRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.firestore.v1.RollbackRequest").msgclass
241
258
  RunQueryRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.firestore.v1.RunQueryRequest").msgclass
242
259
  RunQueryResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.firestore.v1.RunQueryResponse").msgclass
260
+ RunAggregationQueryRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.firestore.v1.RunAggregationQueryRequest").msgclass
261
+ RunAggregationQueryResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.firestore.v1.RunAggregationQueryResponse").msgclass
243
262
  PartitionQueryRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.firestore.v1.PartitionQueryRequest").msgclass
244
263
  PartitionQueryResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.firestore.v1.PartitionQueryResponse").msgclass
245
264
  WriteRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.firestore.v1.WriteRequest").msgclass
@@ -63,6 +63,19 @@ module Google
63
63
  rpc :Rollback, ::Google::Cloud::Firestore::V1::RollbackRequest, ::Google::Protobuf::Empty
64
64
  # Runs a query.
65
65
  rpc :RunQuery, ::Google::Cloud::Firestore::V1::RunQueryRequest, stream(::Google::Cloud::Firestore::V1::RunQueryResponse)
66
+ # Runs an aggregation query.
67
+ #
68
+ # Rather than producing [Document][google.firestore.v1.Document] results like [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery],
69
+ # this API allows running an aggregation to produce a series of
70
+ # [AggregationResult][google.firestore.v1.AggregationResult] server-side.
71
+ #
72
+ # High-Level Example:
73
+ #
74
+ # ```
75
+ # -- Return the number of documents in table given a filter.
76
+ # SELECT COUNT(*) FROM ( SELECT * FROM k where a = true );
77
+ # ```
78
+ rpc :RunAggregationQuery, ::Google::Cloud::Firestore::V1::RunAggregationQueryRequest, stream(::Google::Cloud::Firestore::V1::RunAggregationQueryResponse)
66
79
  # Partitions a query by returning partition cursors that can be used to run
67
80
  # the query in parallel. The returned partition cursors are split points that
68
81
  # can be used by RunQuery as starting/end points for the query results.
@@ -3,6 +3,7 @@
3
3
 
4
4
  require 'google/protobuf'
5
5
 
6
+ require 'google/api/field_behavior_pb'
6
7
  require 'google/firestore/v1/document_pb'
7
8
  require 'google/protobuf/wrappers_pb'
8
9
 
@@ -83,6 +84,21 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
83
84
  value :ASCENDING, 1
84
85
  value :DESCENDING, 2
85
86
  end
87
+ add_message "google.firestore.v1.StructuredAggregationQuery" do
88
+ repeated :aggregations, :message, 3, "google.firestore.v1.StructuredAggregationQuery.Aggregation"
89
+ oneof :query_type do
90
+ optional :structured_query, :message, 1, "google.firestore.v1.StructuredQuery"
91
+ end
92
+ end
93
+ add_message "google.firestore.v1.StructuredAggregationQuery.Aggregation" do
94
+ optional :alias, :string, 7
95
+ oneof :operator do
96
+ optional :count, :message, 1, "google.firestore.v1.StructuredAggregationQuery.Aggregation.Count"
97
+ end
98
+ end
99
+ add_message "google.firestore.v1.StructuredAggregationQuery.Aggregation.Count" do
100
+ optional :up_to, :message, 1, "google.protobuf.Int64Value"
101
+ end
86
102
  add_message "google.firestore.v1.Cursor" do
87
103
  repeated :values, :message, 1, "google.firestore.v1.Value"
88
104
  optional :before, :bool, 2
@@ -107,6 +123,9 @@ module Google
107
123
  StructuredQuery::FieldReference = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.firestore.v1.StructuredQuery.FieldReference").msgclass
108
124
  StructuredQuery::Projection = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.firestore.v1.StructuredQuery.Projection").msgclass
109
125
  StructuredQuery::Direction = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.firestore.v1.StructuredQuery.Direction").enummodule
126
+ StructuredAggregationQuery = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.firestore.v1.StructuredAggregationQuery").msgclass
127
+ StructuredAggregationQuery::Aggregation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.firestore.v1.StructuredAggregationQuery.Aggregation").msgclass
128
+ StructuredAggregationQuery::Aggregation::Count = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.firestore.v1.StructuredAggregationQuery.Aggregation.Count").msgclass
110
129
  Cursor = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.firestore.v1.Cursor").msgclass
111
130
  end
112
131
  end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2022 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+
20
+ module Google
21
+ module Cloud
22
+ module Firestore
23
+ module V1
24
+ # The result of a single bucket from a Firestore aggregation query.
25
+ #
26
+ # The keys of `aggregate_fields` are the same for all results in an aggregation
27
+ # query, unlike document queries which can have different fields present for
28
+ # each result.
29
+ # @!attribute [rw] aggregate_fields
30
+ # @return [::Google::Protobuf::Map{::String => ::Google::Cloud::Firestore::V1::Value}]
31
+ # The result of the aggregation functions, ex: `COUNT(*) AS total_docs`.
32
+ #
33
+ # The key is the {::Google::Cloud::Firestore::V1::StructuredAggregationQuery::Aggregation#alias alias}
34
+ # assigned to the aggregation function on input and the size of this map
35
+ # equals the number of aggregation functions in the query.
36
+ class AggregationResult
37
+ include ::Google::Protobuf::MessageExts
38
+ extend ::Google::Protobuf::MessageExts::ClassMethods
39
+
40
+ # @!attribute [rw] key
41
+ # @return [::String]
42
+ # @!attribute [rw] value
43
+ # @return [::Google::Cloud::Firestore::V1::Value]
44
+ class AggregateFieldsEntry
45
+ include ::Google::Protobuf::MessageExts
46
+ extend ::Google::Protobuf::MessageExts::ClassMethods
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -369,6 +369,61 @@ module Google
369
369
  extend ::Google::Protobuf::MessageExts::ClassMethods
370
370
  end
371
371
 
372
+ # The request for {::Google::Cloud::Firestore::V1::Firestore::Client#run_aggregation_query Firestore.RunAggregationQuery}.
373
+ # @!attribute [rw] parent
374
+ # @return [::String]
375
+ # Required. The parent resource name. In the format:
376
+ # `projects/{project_id}/databases/{database_id}/documents` or
377
+ # `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
378
+ # For example:
379
+ # `projects/my-project/databases/my-database/documents` or
380
+ # `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
381
+ # @!attribute [rw] structured_aggregation_query
382
+ # @return [::Google::Cloud::Firestore::V1::StructuredAggregationQuery]
383
+ # An aggregation query.
384
+ # @!attribute [rw] transaction
385
+ # @return [::String]
386
+ # Run the aggregation within an already active transaction.
387
+ #
388
+ # The value here is the opaque transaction ID to execute the query in.
389
+ # @!attribute [rw] new_transaction
390
+ # @return [::Google::Cloud::Firestore::V1::TransactionOptions]
391
+ # Starts a new transaction as part of the query, defaulting to read-only.
392
+ #
393
+ # The new transaction ID will be returned as the first response in the
394
+ # stream.
395
+ # @!attribute [rw] read_time
396
+ # @return [::Google::Protobuf::Timestamp]
397
+ # Executes the query at the given timestamp.
398
+ #
399
+ # Requires:
400
+ #
401
+ # * Cannot be more than 270 seconds in the past.
402
+ class RunAggregationQueryRequest
403
+ include ::Google::Protobuf::MessageExts
404
+ extend ::Google::Protobuf::MessageExts::ClassMethods
405
+ end
406
+
407
+ # The response for {::Google::Cloud::Firestore::V1::Firestore::Client#run_aggregation_query Firestore.RunAggregationQuery}.
408
+ # @!attribute [rw] result
409
+ # @return [::Google::Cloud::Firestore::V1::AggregationResult]
410
+ # A single aggregation result.
411
+ #
412
+ # Not present when reporting partial progress.
413
+ # @!attribute [rw] transaction
414
+ # @return [::String]
415
+ # The transaction that was started as part of this request.
416
+ #
417
+ # Only present on the first response when the request requested to start
418
+ # a new transaction.
419
+ # @!attribute [rw] read_time
420
+ # @return [::Google::Protobuf::Timestamp]
421
+ # The time at which the aggregate value is valid for.
422
+ class RunAggregationQueryResponse
423
+ include ::Google::Protobuf::MessageExts
424
+ extend ::Google::Protobuf::MessageExts::ClassMethods
425
+ end
426
+
372
427
  # The request for {::Google::Cloud::Firestore::V1::Firestore::Client#partition_query Firestore.PartitionQuery}.
373
428
  # @!attribute [rw] parent
374
429
  # @return [::String]
@@ -55,22 +55,67 @@ module Google
55
55
  # `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
56
56
  # @!attribute [rw] start_at
57
57
  # @return [::Google::Cloud::Firestore::V1::Cursor]
58
- # A starting point for the query results.
58
+ # A potential prefix of a position in the result set to start the query at.
59
+ #
60
+ # The ordering of the result set is based on the `ORDER BY` clause of the
61
+ # original query.
62
+ #
63
+ # ```
64
+ # SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, __name__ ASC;
65
+ # ```
66
+ #
67
+ # This query's results are ordered by `(b ASC, __name__ ASC)`.
68
+ #
69
+ # Cursors can reference either the full ordering or a prefix of the location,
70
+ # though it cannot reference more fields than what are in the provided
71
+ # `ORDER BY`.
72
+ #
73
+ # Continuing off the example above, attaching the following start cursors
74
+ # will have varying impact:
75
+ #
76
+ # - `START BEFORE (2, /k/123)`: start the query right before `a = 1 AND
77
+ # b > 2 AND __name__ > /k/123`.
78
+ # - `START AFTER (10)`: start the query right after `a = 1 AND b > 10`.
79
+ #
80
+ # Unlike `OFFSET` which requires scanning over the first N results to skip,
81
+ # a start cursor allows the query to begin at a logical position. This
82
+ # position is not required to match an actual result, it will scan forward
83
+ # from this position to find the next document.
84
+ #
85
+ # Requires:
86
+ #
87
+ # * The number of values cannot be greater than the number of fields
88
+ # specified in the `ORDER BY` clause.
59
89
  # @!attribute [rw] end_at
60
90
  # @return [::Google::Cloud::Firestore::V1::Cursor]
61
- # A end point for the query results.
91
+ # A potential prefix of a position in the result set to end the query at.
92
+ #
93
+ # This is similar to `START_AT` but with it controlling the end position
94
+ # rather than the start position.
95
+ #
96
+ # Requires:
97
+ #
98
+ # * The number of values cannot be greater than the number of fields
99
+ # specified in the `ORDER BY` clause.
62
100
  # @!attribute [rw] offset
63
101
  # @return [::Integer]
64
- # The number of results to skip.
102
+ # The number of documents to skip before returning the first result.
103
+ #
104
+ # This applies after the constraints specified by the `WHERE`, `START AT`, &
105
+ # `END AT` but before the `LIMIT` clause.
65
106
  #
66
- # Applies before limit, but after all other constraints. Must be >= 0 if
67
- # specified.
107
+ # Requires:
108
+ #
109
+ # * The value must be greater than or equal to zero if specified.
68
110
  # @!attribute [rw] limit
69
111
  # @return [::Google::Protobuf::Int32Value]
70
112
  # The maximum number of results to return.
71
113
  #
72
114
  # Applies after all other constraints.
73
- # Must be >= 0 if specified.
115
+ #
116
+ # Requires:
117
+ #
118
+ # * The value must be greater than or equal to zero if specified.
74
119
  class StructuredQuery
75
120
  include ::Google::Protobuf::MessageExts
76
121
  extend ::Google::Protobuf::MessageExts::ClassMethods
@@ -272,9 +317,14 @@ module Google
272
317
  extend ::Google::Protobuf::MessageExts::ClassMethods
273
318
  end
274
319
 
275
- # A reference to a field, such as `max(messages.time) as max_time`.
320
+ # A reference to a field in a document, ex: `stats.operations`.
276
321
  # @!attribute [rw] field_path
277
322
  # @return [::String]
323
+ # The relative path of the document being referenced.
324
+ #
325
+ # Requires:
326
+ #
327
+ # * Conform to {::Google::Cloud::Firestore::V1::Document#fields document field name} limitations.
278
328
  class FieldReference
279
329
  include ::Google::Protobuf::MessageExts
280
330
  extend ::Google::Protobuf::MessageExts::ClassMethods
@@ -305,6 +355,93 @@ module Google
305
355
  end
306
356
  end
307
357
 
358
+ # Firestore query for running an aggregation over a {::Google::Cloud::Firestore::V1::StructuredQuery StructuredQuery}.
359
+ # @!attribute [rw] structured_query
360
+ # @return [::Google::Cloud::Firestore::V1::StructuredQuery]
361
+ # Nested structured query.
362
+ # @!attribute [rw] aggregations
363
+ # @return [::Array<::Google::Cloud::Firestore::V1::StructuredAggregationQuery::Aggregation>]
364
+ # Optional. Series of aggregations to apply over the results of the `structured_query`.
365
+ #
366
+ # Requires:
367
+ #
368
+ # * A minimum of one and maximum of five aggregations per query.
369
+ class StructuredAggregationQuery
370
+ include ::Google::Protobuf::MessageExts
371
+ extend ::Google::Protobuf::MessageExts::ClassMethods
372
+
373
+ # Defines a aggregation that produces a single result.
374
+ # @!attribute [rw] count
375
+ # @return [::Google::Cloud::Firestore::V1::StructuredAggregationQuery::Aggregation::Count]
376
+ # Count aggregator.
377
+ # @!attribute [rw] alias
378
+ # @return [::String]
379
+ # Optional. Optional name of the field to store the result of the aggregation into.
380
+ #
381
+ # If not provided, Firestore will pick a default name following the format
382
+ # `field_<incremental_id++>`. For example:
383
+ #
384
+ # ```
385
+ # AGGREGATE
386
+ # COUNT_UP_TO(1) AS count_up_to_1,
387
+ # COUNT_UP_TO(2),
388
+ # COUNT_UP_TO(3) AS count_up_to_3,
389
+ # COUNT_UP_TO(4)
390
+ # OVER (
391
+ # ...
392
+ # );
393
+ # ```
394
+ #
395
+ # becomes:
396
+ #
397
+ # ```
398
+ # AGGREGATE
399
+ # COUNT_UP_TO(1) AS count_up_to_1,
400
+ # COUNT_UP_TO(2) AS field_1,
401
+ # COUNT_UP_TO(3) AS count_up_to_3,
402
+ # COUNT_UP_TO(4) AS field_2
403
+ # OVER (
404
+ # ...
405
+ # );
406
+ # ```
407
+ #
408
+ # Requires:
409
+ #
410
+ # * Must be unique across all aggregation aliases.
411
+ # * Conform to {::Google::Cloud::Firestore::V1::Document#fields document field name} limitations.
412
+ class Aggregation
413
+ include ::Google::Protobuf::MessageExts
414
+ extend ::Google::Protobuf::MessageExts::ClassMethods
415
+
416
+ # Count of documents that match the query.
417
+ #
418
+ # The `COUNT(*)` aggregation function operates on the entire document
419
+ # so it does not require a field reference.
420
+ # @!attribute [rw] up_to
421
+ # @return [::Google::Protobuf::Int64Value]
422
+ # Optional. Optional constraint on the maximum number of documents to count.
423
+ #
424
+ # This provides a way to set an upper bound on the number of documents
425
+ # to scan, limiting latency and cost.
426
+ #
427
+ # Unspecified is interpreted as no bound.
428
+ #
429
+ # High-Level Example:
430
+ #
431
+ # ```
432
+ # AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
433
+ # ```
434
+ #
435
+ # Requires:
436
+ #
437
+ # * Must be greater than zero when present.
438
+ class Count
439
+ include ::Google::Protobuf::MessageExts
440
+ extend ::Google::Protobuf::MessageExts::ClassMethods
441
+ end
442
+ end
443
+ end
444
+
308
445
  # A position in a query result set.
309
446
  # @!attribute [rw] values
310
447
  # @return [::Array<::Google::Cloud::Firestore::V1::Value>]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-firestore-v1
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Google LLC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-24 00:00:00.000000000 Z
11
+ date: 2022-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gapic-common
@@ -44,6 +44,26 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '1.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: google-cloud-location
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0.0'
54
+ - - "<"
55
+ - !ruby/object:Gem::Version
56
+ version: 2.a
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0.0'
64
+ - - "<"
65
+ - !ruby/object:Gem::Version
66
+ version: 2.a
47
67
  - !ruby/object:Gem::Dependency
48
68
  name: google-style
49
69
  requirement: !ruby/object:Gem::Requirement
@@ -175,6 +195,7 @@ files:
175
195
  - lib/google/cloud/firestore/v1/firestore/client.rb
176
196
  - lib/google/cloud/firestore/v1/firestore/credentials.rb
177
197
  - lib/google/cloud/firestore/v1/version.rb
198
+ - lib/google/firestore/v1/aggregation_result_pb.rb
178
199
  - lib/google/firestore/v1/common_pb.rb
179
200
  - lib/google/firestore/v1/document_pb.rb
180
201
  - lib/google/firestore/v1/firestore_pb.rb
@@ -184,6 +205,7 @@ files:
184
205
  - proto_docs/README.md
185
206
  - proto_docs/google/api/field_behavior.rb
186
207
  - proto_docs/google/api/resource.rb
208
+ - proto_docs/google/firestore/v1/aggregation_result.rb
187
209
  - proto_docs/google/firestore/v1/common.rb
188
210
  - proto_docs/google/firestore/v1/document.rb
189
211
  - proto_docs/google/firestore/v1/firestore.rb