google-cloud-firestore 1.4.4 → 2.0.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 (79) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +1 -1
  3. data/CHANGELOG.md +23 -0
  4. data/lib/google-cloud-firestore.rb +14 -21
  5. data/lib/google/cloud/firestore.rb +12 -23
  6. data/lib/google/cloud/firestore/client.rb +12 -14
  7. data/lib/google/cloud/firestore/collection_reference.rb +1 -0
  8. data/lib/google/cloud/firestore/collection_reference_list.rb +137 -0
  9. data/lib/google/cloud/firestore/convert.rb +39 -39
  10. data/lib/google/cloud/firestore/credentials.rb +2 -2
  11. data/lib/google/cloud/firestore/document_reference.rb +8 -8
  12. data/lib/google/cloud/firestore/document_reference/list.rb +2 -2
  13. data/lib/google/cloud/firestore/document_snapshot.rb +4 -4
  14. data/lib/google/cloud/firestore/query.rb +4 -4
  15. data/lib/google/cloud/firestore/service.rb +63 -104
  16. data/lib/google/cloud/firestore/transaction.rb +2 -2
  17. data/lib/google/cloud/firestore/version.rb +1 -1
  18. data/lib/google/cloud/firestore/watch/listener.rb +9 -9
  19. data/lib/google/cloud/firestore/watch/order.rb +1 -1
  20. metadata +9 -107
  21. data/lib/google/cloud/firestore/admin.rb +0 -144
  22. data/lib/google/cloud/firestore/admin/v1.rb +0 -151
  23. data/lib/google/cloud/firestore/admin/v1/credentials.rb +0 -44
  24. data/lib/google/cloud/firestore/admin/v1/doc/google/firestore/admin/v1/field.rb +0 -86
  25. data/lib/google/cloud/firestore/admin/v1/doc/google/firestore/admin/v1/firestore_admin.rb +0 -161
  26. data/lib/google/cloud/firestore/admin/v1/doc/google/firestore/admin/v1/index.rb +0 -142
  27. data/lib/google/cloud/firestore/admin/v1/doc/google/longrunning/operations.rb +0 -51
  28. data/lib/google/cloud/firestore/admin/v1/doc/google/protobuf/any.rb +0 -131
  29. data/lib/google/cloud/firestore/admin/v1/doc/google/protobuf/empty.rb +0 -29
  30. data/lib/google/cloud/firestore/admin/v1/doc/google/protobuf/field_mask.rb +0 -222
  31. data/lib/google/cloud/firestore/admin/v1/doc/google/rpc/status.rb +0 -39
  32. data/lib/google/cloud/firestore/admin/v1/firestore_admin_client.rb +0 -902
  33. data/lib/google/cloud/firestore/admin/v1/firestore_admin_client_config.json +0 -76
  34. data/lib/google/cloud/firestore/v1.rb +0 -152
  35. data/lib/google/cloud/firestore/v1/credentials.rb +0 -42
  36. data/lib/google/cloud/firestore/v1/doc/google/firestore/v1/common.rb +0 -64
  37. data/lib/google/cloud/firestore/v1/doc/google/firestore/v1/document.rb +0 -136
  38. data/lib/google/cloud/firestore/v1/doc/google/firestore/v1/firestore.rb +0 -566
  39. data/lib/google/cloud/firestore/v1/doc/google/firestore/v1/query.rb +0 -227
  40. data/lib/google/cloud/firestore/v1/doc/google/firestore/v1/write.rb +0 -241
  41. data/lib/google/cloud/firestore/v1/doc/google/protobuf/any.rb +0 -131
  42. data/lib/google/cloud/firestore/v1/doc/google/protobuf/empty.rb +0 -29
  43. data/lib/google/cloud/firestore/v1/doc/google/protobuf/timestamp.rb +0 -113
  44. data/lib/google/cloud/firestore/v1/doc/google/protobuf/wrappers.rb +0 -26
  45. data/lib/google/cloud/firestore/v1/doc/google/rpc/status.rb +0 -39
  46. data/lib/google/cloud/firestore/v1/firestore_client.rb +0 -1011
  47. data/lib/google/cloud/firestore/v1/firestore_client_config.json +0 -105
  48. data/lib/google/cloud/firestore/v1beta1.rb +0 -162
  49. data/lib/google/cloud/firestore/v1beta1/credentials.rb +0 -42
  50. data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/common.rb +0 -64
  51. data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/document.rb +0 -136
  52. data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/firestore.rb +0 -564
  53. data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/query.rb +0 -227
  54. data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/write.rb +0 -237
  55. data/lib/google/cloud/firestore/v1beta1/doc/google/protobuf/any.rb +0 -131
  56. data/lib/google/cloud/firestore/v1beta1/doc/google/protobuf/empty.rb +0 -29
  57. data/lib/google/cloud/firestore/v1beta1/doc/google/protobuf/timestamp.rb +0 -113
  58. data/lib/google/cloud/firestore/v1beta1/doc/google/protobuf/wrappers.rb +0 -26
  59. data/lib/google/cloud/firestore/v1beta1/doc/google/rpc/status.rb +0 -39
  60. data/lib/google/cloud/firestore/v1beta1/firestore_client.rb +0 -1021
  61. data/lib/google/cloud/firestore/v1beta1/firestore_client_config.json +0 -100
  62. data/lib/google/firestore/admin/v1/field_pb.rb +0 -32
  63. data/lib/google/firestore/admin/v1/firestore_admin_pb.rb +0 -84
  64. data/lib/google/firestore/admin/v1/firestore_admin_services_pb.rb +0 -94
  65. data/lib/google/firestore/admin/v1/index_pb.rb +0 -58
  66. data/lib/google/firestore/admin/v1/location_pb.rb +0 -22
  67. data/lib/google/firestore/admin/v1/operation_pb.rb +0 -90
  68. data/lib/google/firestore/v1/common_pb.rb +0 -45
  69. data/lib/google/firestore/v1/document_pb.rb +0 -50
  70. data/lib/google/firestore/v1/firestore_pb.rb +0 -222
  71. data/lib/google/firestore/v1/firestore_services_pb.rb +0 -80
  72. data/lib/google/firestore/v1/query_pb.rb +0 -107
  73. data/lib/google/firestore/v1/write_pb.rb +0 -80
  74. data/lib/google/firestore/v1beta1/common_pb.rb +0 -45
  75. data/lib/google/firestore/v1beta1/document_pb.rb +0 -50
  76. data/lib/google/firestore/v1beta1/firestore_pb.rb +0 -222
  77. data/lib/google/firestore/v1beta1/firestore_services_pb.rb +0 -89
  78. data/lib/google/firestore/v1beta1/query_pb.rb +0 -107
  79. data/lib/google/firestore/v1beta1/write_pb.rb +0 -79
@@ -1,131 +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 Protobuf
18
- # `Any` contains an arbitrary serialized protocol buffer message along with a
19
- # URL that describes the type of the serialized message.
20
- #
21
- # Protobuf library provides support to pack/unpack Any values in the form
22
- # of utility functions or additional generated methods of the Any type.
23
- #
24
- # Example 1: Pack and unpack a message in C++.
25
- #
26
- # Foo foo = ...;
27
- # Any any;
28
- # any.PackFrom(foo);
29
- # ...
30
- # if (any.UnpackTo(&foo)) {
31
- # ...
32
- # }
33
- #
34
- # Example 2: Pack and unpack a message in Java.
35
- #
36
- # Foo foo = ...;
37
- # Any any = Any.pack(foo);
38
- # ...
39
- # if (any.is(Foo.class)) {
40
- # foo = any.unpack(Foo.class);
41
- # }
42
- #
43
- # Example 3: Pack and unpack a message in Python.
44
- #
45
- # foo = Foo(...)
46
- # any = Any()
47
- # any.Pack(foo)
48
- # ...
49
- # if any.Is(Foo.DESCRIPTOR):
50
- # any.Unpack(foo)
51
- # ...
52
- #
53
- # Example 4: Pack and unpack a message in Go
54
- #
55
- # foo := &pb.Foo{...}
56
- # any, err := ptypes.MarshalAny(foo)
57
- # ...
58
- # foo := &pb.Foo{}
59
- # if err := ptypes.UnmarshalAny(any, foo); err != nil {
60
- # ...
61
- # }
62
- #
63
- # The pack methods provided by protobuf library will by default use
64
- # 'type.googleapis.com/full.type.name' as the type URL and the unpack
65
- # methods only use the fully qualified type name after the last '/'
66
- # in the type URL, for example "foo.bar.com/x/y.z" will yield type
67
- # name "y.z".
68
- #
69
- #
70
- # = JSON
71
- #
72
- # The JSON representation of an `Any` value uses the regular
73
- # representation of the deserialized, embedded message, with an
74
- # additional field `@type` which contains the type URL. Example:
75
- #
76
- # package google.profile;
77
- # message Person {
78
- # string first_name = 1;
79
- # string last_name = 2;
80
- # }
81
- #
82
- # {
83
- # "@type": "type.googleapis.com/google.profile.Person",
84
- # "firstName": <string>,
85
- # "lastName": <string>
86
- # }
87
- #
88
- # If the embedded message type is well-known and has a custom JSON
89
- # representation, that representation will be embedded adding a field
90
- # `value` which holds the custom JSON in addition to the `@type`
91
- # field. Example (for message {Google::Protobuf::Duration}):
92
- #
93
- # {
94
- # "@type": "type.googleapis.com/google.protobuf.Duration",
95
- # "value": "1.212s"
96
- # }
97
- # @!attribute [rw] type_url
98
- # @return [String]
99
- # A URL/resource name that uniquely identifies the type of the serialized
100
- # protocol buffer message. This string must contain at least
101
- # one "/" character. The last segment of the URL's path must represent
102
- # the fully qualified name of the type (as in
103
- # `path/google.protobuf.Duration`). The name should be in a canonical form
104
- # (e.g., leading "." is not accepted).
105
- #
106
- # In practice, teams usually precompile into the binary all types that they
107
- # expect it to use in the context of Any. However, for URLs which use the
108
- # scheme `http`, `https`, or no scheme, one can optionally set up a type
109
- # server that maps type URLs to message definitions as follows:
110
- #
111
- # * If no scheme is provided, `https` is assumed.
112
- # * An HTTP GET on the URL must yield a {Google::Protobuf::Type}
113
- # value in binary format, or produce an error.
114
- # * Applications are allowed to cache lookup results based on the
115
- # URL, or have them precompiled into a binary to avoid any
116
- # lookup. Therefore, binary compatibility needs to be preserved
117
- # on changes to types. (Use versioned type names to manage
118
- # breaking changes.)
119
- #
120
- # Note: this functionality is not currently available in the official
121
- # protobuf release, and it is not used for type URLs beginning with
122
- # type.googleapis.com.
123
- #
124
- # Schemes other than `http`, `https` (or the empty scheme) might be
125
- # used with implementation specific semantics.
126
- # @!attribute [rw] value
127
- # @return [String]
128
- # Must be a valid serialized protocol buffer of the above specified type.
129
- class Any; end
130
- end
131
- end
@@ -1,29 +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 Protobuf
18
- # A generic empty message that you can re-use to avoid defining duplicated
19
- # empty messages in your APIs. A typical example is to use it as the request
20
- # or the response type of an API method. For instance:
21
- #
22
- # service Foo {
23
- # rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
24
- # }
25
- #
26
- # The JSON representation for `Empty` is empty JSON object `{}`.
27
- class Empty; end
28
- end
29
- end
@@ -1,113 +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 Protobuf
18
- # A Timestamp represents a point in time independent of any time zone or local
19
- # calendar, encoded as a count of seconds and fractions of seconds at
20
- # nanosecond resolution. The count is relative to an epoch at UTC midnight on
21
- # January 1, 1970, in the proleptic Gregorian calendar which extends the
22
- # Gregorian calendar backwards to year one.
23
- #
24
- # All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
25
- # second table is needed for interpretation, using a [24-hour linear
26
- # smear](https://developers.google.com/time/smear).
27
- #
28
- # The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
29
- # restricting to that range, we ensure that we can convert to and from [RFC
30
- # 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
31
- #
32
- # = Examples
33
- #
34
- # Example 1: Compute Timestamp from POSIX `time()`.
35
- #
36
- # Timestamp timestamp;
37
- # timestamp.set_seconds(time(NULL));
38
- # timestamp.set_nanos(0);
39
- #
40
- # Example 2: Compute Timestamp from POSIX `gettimeofday()`.
41
- #
42
- # struct timeval tv;
43
- # gettimeofday(&tv, NULL);
44
- #
45
- # Timestamp timestamp;
46
- # timestamp.set_seconds(tv.tv_sec);
47
- # timestamp.set_nanos(tv.tv_usec * 1000);
48
- #
49
- # Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
50
- #
51
- # FILETIME ft;
52
- # GetSystemTimeAsFileTime(&ft);
53
- # UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
54
- #
55
- # // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
56
- # // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
57
- # Timestamp timestamp;
58
- # timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
59
- # timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
60
- #
61
- # Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
62
- #
63
- # long millis = System.currentTimeMillis();
64
- #
65
- # Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
66
- # .setNanos((int) ((millis % 1000) * 1000000)).build();
67
- #
68
- #
69
- # Example 5: Compute Timestamp from current time in Python.
70
- #
71
- # timestamp = Timestamp()
72
- # timestamp.GetCurrentTime()
73
- #
74
- # = JSON Mapping
75
- #
76
- # In JSON format, the Timestamp type is encoded as a string in the
77
- # [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
78
- # format is "\\{year}-\\{month}-\\{day}T\\{hour}:\\{min}:\\{sec}[.\\{frac_sec}]Z"
79
- # where \\{year} is always expressed using four digits while \\{month}, \\{day},
80
- # \\{hour}, \\{min}, and \\{sec} are zero-padded to two digits each. The fractional
81
- # seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
82
- # are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
83
- # is required. A proto3 JSON serializer should always use UTC (as indicated by
84
- # "Z") when printing the Timestamp type and a proto3 JSON parser should be
85
- # able to accept both UTC and other timezones (as indicated by an offset).
86
- #
87
- # For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
88
- # 01:30 UTC on January 15, 2017.
89
- #
90
- # In JavaScript, one can convert a Date object to this format using the
91
- # standard
92
- # [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
93
- # method. In Python, a standard `datetime.datetime` object can be converted
94
- # to this format using
95
- # [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
96
- # the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
97
- # the Joda Time's [`ISODateTimeFormat.dateTime()`](
98
- # http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
99
- # ) to obtain a formatter capable of generating timestamps in this format.
100
- # @!attribute [rw] seconds
101
- # @return [Integer]
102
- # Represents seconds of UTC time since Unix epoch
103
- # 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
104
- # 9999-12-31T23:59:59Z inclusive.
105
- # @!attribute [rw] nanos
106
- # @return [Integer]
107
- # Non-negative fractions of a second at nanosecond resolution. Negative
108
- # second values with fractions must still have non-negative nanos values
109
- # that count forward in time. Must be from 0 to 999,999,999
110
- # inclusive.
111
- class Timestamp; end
112
- end
113
- end
@@ -1,26 +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 Protobuf
18
- # Wrapper message for `int32`.
19
- #
20
- # The JSON representation for `Int32Value` is JSON number.
21
- # @!attribute [rw] value
22
- # @return [Integer]
23
- # The int32 value.
24
- class Int32Value; end
25
- end
26
- end
@@ -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,1011 +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/v1/firestore.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
-
28
- require "google/firestore/v1/firestore_pb"
29
- require "google/cloud/firestore/v1/credentials"
30
- require "google/cloud/firestore/version"
31
-
32
- module Google
33
- module Cloud
34
- module Firestore
35
- module V1
36
- # The Cloud Firestore service.
37
- #
38
- # Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL
39
- # document database that simplifies storing, syncing, and querying data for
40
- # your mobile, web, and IoT apps at global scale. Its client libraries provide
41
- # live synchronization and offline support, while its security features and
42
- # integrations with Firebase and Google Cloud Platform (GCP) accelerate
43
- # building truly serverless apps.
44
- #
45
- # @!attribute [r] firestore_stub
46
- # @return [Google::Firestore::V1::Firestore::Stub]
47
- class FirestoreClient
48
- # @private
49
- attr_reader :firestore_stub
50
-
51
- # The default address of the service.
52
- SERVICE_ADDRESS = "firestore.googleapis.com".freeze
53
-
54
- # The default port of the service.
55
- DEFAULT_SERVICE_PORT = 443
56
-
57
- # The default set of gRPC interceptors.
58
- GRPC_INTERCEPTORS = []
59
-
60
- DEFAULT_TIMEOUT = 30
61
-
62
- PAGE_DESCRIPTORS = {
63
- "list_documents" => Google::Gax::PageDescriptor.new(
64
- "page_token",
65
- "next_page_token",
66
- "documents"),
67
- "list_collection_ids" => Google::Gax::PageDescriptor.new(
68
- "page_token",
69
- "next_page_token",
70
- "collection_ids")
71
- }.freeze
72
-
73
- private_constant :PAGE_DESCRIPTORS
74
-
75
- # The scopes needed to make gRPC calls to all of the methods defined in
76
- # this service.
77
- ALL_SCOPES = [
78
- "https://www.googleapis.com/auth/cloud-platform",
79
- "https://www.googleapis.com/auth/datastore"
80
- ].freeze
81
-
82
-
83
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
84
- # Provides the means for authenticating requests made by the client. This parameter can
85
- # be many types.
86
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
87
- # authenticating requests made by this client.
88
- # A `String` will be treated as the path to the keyfile to be used for the construction of
89
- # credentials for this client.
90
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
91
- # credentials for this client.
92
- # A `GRPC::Core::Channel` will be used to make calls through.
93
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
94
- # should already be composed with a `GRPC::Core::CallCredentials` object.
95
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
96
- # metadata for requests, generally, to give OAuth credentials.
97
- # @param scopes [Array<String>]
98
- # The OAuth scopes for this service. This parameter is ignored if
99
- # an updater_proc is supplied.
100
- # @param client_config [Hash]
101
- # A Hash for call options for each method. See
102
- # Google::Gax#construct_settings for the structure of
103
- # this data. Falls back to the default config if not specified
104
- # or the specified config is missing data points.
105
- # @param timeout [Numeric]
106
- # The default timeout, in seconds, for calls made through this client.
107
- # @param metadata [Hash]
108
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
109
- # @param service_address [String]
110
- # Override for the service hostname, or `nil` to leave as the default.
111
- # @param service_port [Integer]
112
- # Override for the service port, or `nil` to leave as the default.
113
- # @param exception_transformer [Proc]
114
- # An optional proc that intercepts any exceptions raised during an API call to inject
115
- # custom error handling.
116
- def initialize \
117
- credentials: nil,
118
- scopes: ALL_SCOPES,
119
- client_config: {},
120
- timeout: DEFAULT_TIMEOUT,
121
- metadata: nil,
122
- service_address: nil,
123
- service_port: nil,
124
- exception_transformer: nil,
125
- lib_name: nil,
126
- lib_version: ""
127
- # These require statements are intentionally placed here to initialize
128
- # the gRPC module only when it's required.
129
- # See https://github.com/googleapis/toolkit/issues/446
130
- require "google/gax/grpc"
131
- require "google/firestore/v1/firestore_services_pb"
132
-
133
- credentials ||= Google::Cloud::Firestore::V1::Credentials.default
134
-
135
- if credentials.is_a?(String) || credentials.is_a?(Hash)
136
- updater_proc = Google::Cloud::Firestore::V1::Credentials.new(credentials).updater_proc
137
- end
138
- if credentials.is_a?(GRPC::Core::Channel)
139
- channel = credentials
140
- end
141
- if credentials.is_a?(GRPC::Core::ChannelCredentials)
142
- chan_creds = credentials
143
- end
144
- if credentials.is_a?(Proc)
145
- updater_proc = credentials
146
- end
147
- if credentials.is_a?(Google::Auth::Credentials)
148
- updater_proc = credentials.updater_proc
149
- end
150
-
151
- package_version = Google::Cloud::Firestore::VERSION
152
-
153
- google_api_client = "gl-ruby/#{RUBY_VERSION}"
154
- google_api_client << " #{lib_name}/#{lib_version}" if lib_name
155
- google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
156
- google_api_client << " grpc/#{GRPC::VERSION}"
157
- google_api_client.freeze
158
-
159
- headers = { :"x-goog-api-client" => google_api_client }
160
- if credentials.respond_to?(:quota_project_id) && credentials.quota_project_id
161
- headers[:"x-goog-user-project"] = credentials.quota_project_id
162
- end
163
- headers.merge!(metadata) unless metadata.nil?
164
- client_config_file = Pathname.new(__dir__).join(
165
- "firestore_client_config.json"
166
- )
167
- defaults = client_config_file.open do |f|
168
- Google::Gax.construct_settings(
169
- "google.firestore.v1.Firestore",
170
- JSON.parse(f.read),
171
- client_config,
172
- Google::Gax::Grpc::STATUS_CODE_NAMES,
173
- timeout,
174
- page_descriptors: PAGE_DESCRIPTORS,
175
- errors: Google::Gax::Grpc::API_ERRORS,
176
- metadata: headers
177
- )
178
- end
179
-
180
- # Allow overriding the service path/port in subclasses.
181
- service_path = service_address || self.class::SERVICE_ADDRESS
182
- port = service_port || self.class::DEFAULT_SERVICE_PORT
183
- interceptors = self.class::GRPC_INTERCEPTORS
184
- @firestore_stub = Google::Gax::Grpc.create_stub(
185
- service_path,
186
- port,
187
- chan_creds: chan_creds,
188
- channel: channel,
189
- updater_proc: updater_proc,
190
- scopes: scopes,
191
- interceptors: interceptors,
192
- &Google::Firestore::V1::Firestore::Stub.method(:new)
193
- )
194
-
195
- @get_document = Google::Gax.create_api_call(
196
- @firestore_stub.method(:get_document),
197
- defaults["get_document"],
198
- exception_transformer: exception_transformer,
199
- params_extractor: proc do |request|
200
- {'name' => request.name}
201
- end
202
- )
203
- @list_documents = Google::Gax.create_api_call(
204
- @firestore_stub.method(:list_documents),
205
- defaults["list_documents"],
206
- exception_transformer: exception_transformer
207
- )
208
- @create_document = Google::Gax.create_api_call(
209
- @firestore_stub.method(:create_document),
210
- defaults["create_document"],
211
- exception_transformer: exception_transformer
212
- )
213
- @update_document = Google::Gax.create_api_call(
214
- @firestore_stub.method(:update_document),
215
- defaults["update_document"],
216
- exception_transformer: exception_transformer,
217
- params_extractor: proc do |request|
218
- {'document.name' => request.document.name}
219
- end
220
- )
221
- @delete_document = Google::Gax.create_api_call(
222
- @firestore_stub.method(:delete_document),
223
- defaults["delete_document"],
224
- exception_transformer: exception_transformer,
225
- params_extractor: proc do |request|
226
- {'name' => request.name}
227
- end
228
- )
229
- @batch_get_documents = Google::Gax.create_api_call(
230
- @firestore_stub.method(:batch_get_documents),
231
- defaults["batch_get_documents"],
232
- exception_transformer: exception_transformer,
233
- params_extractor: proc do |request|
234
- {'database' => request.database}
235
- end
236
- )
237
- @begin_transaction = Google::Gax.create_api_call(
238
- @firestore_stub.method(:begin_transaction),
239
- defaults["begin_transaction"],
240
- exception_transformer: exception_transformer,
241
- params_extractor: proc do |request|
242
- {'database' => request.database}
243
- end
244
- )
245
- @commit = Google::Gax.create_api_call(
246
- @firestore_stub.method(:commit),
247
- defaults["commit"],
248
- exception_transformer: exception_transformer,
249
- params_extractor: proc do |request|
250
- {'database' => request.database}
251
- end
252
- )
253
- @rollback = Google::Gax.create_api_call(
254
- @firestore_stub.method(:rollback),
255
- defaults["rollback"],
256
- exception_transformer: exception_transformer,
257
- params_extractor: proc do |request|
258
- {'database' => request.database}
259
- end
260
- )
261
- @run_query = Google::Gax.create_api_call(
262
- @firestore_stub.method(:run_query),
263
- defaults["run_query"],
264
- exception_transformer: exception_transformer,
265
- params_extractor: proc do |request|
266
- {'parent' => request.parent}
267
- end
268
- )
269
- @write = Google::Gax.create_api_call(
270
- @firestore_stub.method(:write),
271
- defaults["write"],
272
- exception_transformer: exception_transformer
273
- )
274
- @listen = Google::Gax.create_api_call(
275
- @firestore_stub.method(:listen),
276
- defaults["listen"],
277
- exception_transformer: exception_transformer
278
- )
279
- @list_collection_ids = Google::Gax.create_api_call(
280
- @firestore_stub.method(:list_collection_ids),
281
- defaults["list_collection_ids"],
282
- exception_transformer: exception_transformer,
283
- params_extractor: proc do |request|
284
- {'parent' => request.parent}
285
- end
286
- )
287
- end
288
-
289
- # Service calls
290
-
291
- # Gets a single document.
292
- #
293
- # @param name [String]
294
- # Required. The resource name of the Document to get. In the format:
295
- # `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
296
- # @param mask [Google::Firestore::V1::DocumentMask | Hash]
297
- # The fields to return. If not set, returns all fields.
298
- #
299
- # If the document has a field that is not present in this mask, that field
300
- # will not be returned in the response.
301
- # A hash of the same form as `Google::Firestore::V1::DocumentMask`
302
- # can also be provided.
303
- # @param transaction [String]
304
- # Reads the document in a transaction.
305
- # @param read_time [Google::Protobuf::Timestamp | Hash]
306
- # Reads the version of the document at the given time.
307
- # This may not be older than 60 seconds.
308
- # A hash of the same form as `Google::Protobuf::Timestamp`
309
- # can also be provided.
310
- # @param options [Google::Gax::CallOptions]
311
- # Overrides the default settings for this call, e.g, timeout,
312
- # retries, etc.
313
- # @yield [result, operation] Access the result along with the RPC operation
314
- # @yieldparam result [Google::Firestore::V1::Document]
315
- # @yieldparam operation [GRPC::ActiveCall::Operation]
316
- # @return [Google::Firestore::V1::Document]
317
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
318
- # @example
319
- # require "google/cloud/firestore/v1"
320
- #
321
- # firestore_client = Google::Cloud::Firestore::V1.new
322
- #
323
- # # TODO: Initialize `name`:
324
- # name = ''
325
- # response = firestore_client.get_document(name)
326
-
327
- def get_document \
328
- name,
329
- mask: nil,
330
- transaction: nil,
331
- read_time: nil,
332
- options: nil,
333
- &block
334
- req = {
335
- name: name,
336
- mask: mask,
337
- transaction: transaction,
338
- read_time: read_time
339
- }.delete_if { |_, v| v.nil? }
340
- req = Google::Gax::to_proto(req, Google::Firestore::V1::GetDocumentRequest)
341
- @get_document.call(req, options, &block)
342
- end
343
-
344
- # Lists documents.
345
- #
346
- # @param parent [String]
347
- # Required. The parent resource name. In the format:
348
- # `projects/{project_id}/databases/{database_id}/documents` or
349
- # `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
350
- # For example:
351
- # `projects/my-project/databases/my-database/documents` or
352
- # `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
353
- # @param collection_id [String]
354
- # Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`
355
- # or `messages`.
356
- # @param page_size [Integer]
357
- # The maximum number of resources contained in the underlying API
358
- # response. If page streaming is performed per-resource, this
359
- # parameter does not affect the return value. If page streaming is
360
- # performed per-page, this determines the maximum number of
361
- # resources in a page.
362
- # @param order_by [String]
363
- # The order to sort results by. For example: `priority desc, name`.
364
- # @param mask [Google::Firestore::V1::DocumentMask | Hash]
365
- # The fields to return. If not set, returns all fields.
366
- #
367
- # If a document has a field that is not present in this mask, that field
368
- # will not be returned in the response.
369
- # A hash of the same form as `Google::Firestore::V1::DocumentMask`
370
- # can also be provided.
371
- # @param transaction [String]
372
- # Reads documents in a transaction.
373
- # @param read_time [Google::Protobuf::Timestamp | Hash]
374
- # Reads documents as they were at the given time.
375
- # This may not be older than 60 seconds.
376
- # A hash of the same form as `Google::Protobuf::Timestamp`
377
- # can also be provided.
378
- # @param show_missing [true, false]
379
- # If the list should show missing documents. A missing document is a
380
- # document that does not exist but has sub-documents. These documents will
381
- # be returned with a key but will not have fields, {Google::Firestore::V1::Document#create_time Document#create_time},
382
- # or {Google::Firestore::V1::Document#update_time Document#update_time} set.
383
- #
384
- # Requests with `show_missing` may not specify `where` or
385
- # `order_by`.
386
- # @param options [Google::Gax::CallOptions]
387
- # Overrides the default settings for this call, e.g, timeout,
388
- # retries, etc.
389
- # @yield [result, operation] Access the result along with the RPC operation
390
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Firestore::V1::Document>]
391
- # @yieldparam operation [GRPC::ActiveCall::Operation]
392
- # @return [Google::Gax::PagedEnumerable<Google::Firestore::V1::Document>]
393
- # An enumerable of Google::Firestore::V1::Document instances.
394
- # See Google::Gax::PagedEnumerable documentation for other
395
- # operations such as per-page iteration or access to the response
396
- # object.
397
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
398
- # @example
399
- # require "google/cloud/firestore/v1"
400
- #
401
- # firestore_client = Google::Cloud::Firestore::V1.new
402
- #
403
- # # TODO: Initialize `parent`:
404
- # parent = ''
405
- #
406
- # # TODO: Initialize `collection_id`:
407
- # collection_id = ''
408
- #
409
- # # Iterate over all results.
410
- # firestore_client.list_documents(parent, collection_id).each do |element|
411
- # # Process element.
412
- # end
413
- #
414
- # # Or iterate over results one page at a time.
415
- # firestore_client.list_documents(parent, collection_id).each_page do |page|
416
- # # Process each page at a time.
417
- # page.each do |element|
418
- # # Process element.
419
- # end
420
- # end
421
-
422
- def list_documents \
423
- parent,
424
- collection_id,
425
- page_size: nil,
426
- order_by: nil,
427
- mask: nil,
428
- transaction: nil,
429
- read_time: nil,
430
- show_missing: nil,
431
- options: nil,
432
- &block
433
- req = {
434
- parent: parent,
435
- collection_id: collection_id,
436
- page_size: page_size,
437
- order_by: order_by,
438
- mask: mask,
439
- transaction: transaction,
440
- read_time: read_time,
441
- show_missing: show_missing
442
- }.delete_if { |_, v| v.nil? }
443
- req = Google::Gax::to_proto(req, Google::Firestore::V1::ListDocumentsRequest)
444
- @list_documents.call(req, options, &block)
445
- end
446
-
447
- # Creates a new document.
448
- #
449
- # @param parent [String]
450
- # Required. The parent resource. For example:
451
- # `projects/{project_id}/databases/{database_id}/documents` or
452
- # `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}`
453
- # @param collection_id [String]
454
- # Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`.
455
- # @param document [Google::Firestore::V1::Document | Hash]
456
- # Required. The document to create. `name` must not be set.
457
- # A hash of the same form as `Google::Firestore::V1::Document`
458
- # can also be provided.
459
- # @param document_id [String]
460
- # The client-assigned document ID to use for this document.
461
- #
462
- # Optional. If not specified, an ID will be assigned by the service.
463
- # @param mask [Google::Firestore::V1::DocumentMask | Hash]
464
- # The fields to return. If not set, returns all fields.
465
- #
466
- # If the document has a field that is not present in this mask, that field
467
- # will not be returned in the response.
468
- # A hash of the same form as `Google::Firestore::V1::DocumentMask`
469
- # can also be provided.
470
- # @param options [Google::Gax::CallOptions]
471
- # Overrides the default settings for this call, e.g, timeout,
472
- # retries, etc.
473
- # @yield [result, operation] Access the result along with the RPC operation
474
- # @yieldparam result [Google::Firestore::V1::Document]
475
- # @yieldparam operation [GRPC::ActiveCall::Operation]
476
- # @return [Google::Firestore::V1::Document]
477
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
478
- # @example
479
- # require "google/cloud/firestore/v1"
480
- #
481
- # firestore_client = Google::Cloud::Firestore::V1.new
482
- #
483
- # # TODO: Initialize `parent`:
484
- # parent = ''
485
- #
486
- # # TODO: Initialize `collection_id`:
487
- # collection_id = ''
488
- #
489
- # # TODO: Initialize `document`:
490
- # document = {}
491
- # response = firestore_client.create_document(parent, collection_id, document)
492
-
493
- def create_document \
494
- parent,
495
- collection_id,
496
- document,
497
- document_id: nil,
498
- mask: nil,
499
- options: nil,
500
- &block
501
- req = {
502
- parent: parent,
503
- collection_id: collection_id,
504
- document: document,
505
- document_id: document_id,
506
- mask: mask
507
- }.delete_if { |_, v| v.nil? }
508
- req = Google::Gax::to_proto(req, Google::Firestore::V1::CreateDocumentRequest)
509
- @create_document.call(req, options, &block)
510
- end
511
-
512
- # Updates or inserts a document.
513
- #
514
- # @param document [Google::Firestore::V1::Document | Hash]
515
- # Required. The updated document.
516
- # Creates the document if it does not already exist.
517
- # A hash of the same form as `Google::Firestore::V1::Document`
518
- # can also be provided.
519
- # @param update_mask [Google::Firestore::V1::DocumentMask | Hash]
520
- # The fields to update.
521
- # None of the field paths in the mask may contain a reserved name.
522
- #
523
- # If the document exists on the server and has fields not referenced in the
524
- # mask, they are left unchanged.
525
- # Fields referenced in the mask, but not present in the input document, are
526
- # deleted from the document on the server.
527
- # A hash of the same form as `Google::Firestore::V1::DocumentMask`
528
- # can also be provided.
529
- # @param mask [Google::Firestore::V1::DocumentMask | Hash]
530
- # The fields to return. If not set, returns all fields.
531
- #
532
- # If the document has a field that is not present in this mask, that field
533
- # will not be returned in the response.
534
- # A hash of the same form as `Google::Firestore::V1::DocumentMask`
535
- # can also be provided.
536
- # @param current_document [Google::Firestore::V1::Precondition | Hash]
537
- # An optional precondition on the document.
538
- # The request will fail if this is set and not met by the target document.
539
- # A hash of the same form as `Google::Firestore::V1::Precondition`
540
- # can also be provided.
541
- # @param options [Google::Gax::CallOptions]
542
- # Overrides the default settings for this call, e.g, timeout,
543
- # retries, etc.
544
- # @yield [result, operation] Access the result along with the RPC operation
545
- # @yieldparam result [Google::Firestore::V1::Document]
546
- # @yieldparam operation [GRPC::ActiveCall::Operation]
547
- # @return [Google::Firestore::V1::Document]
548
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
549
- # @example
550
- # require "google/cloud/firestore/v1"
551
- #
552
- # firestore_client = Google::Cloud::Firestore::V1.new
553
- #
554
- # # TODO: Initialize `document`:
555
- # document = {}
556
- # response = firestore_client.update_document(document)
557
-
558
- def update_document \
559
- document,
560
- update_mask: nil,
561
- mask: nil,
562
- current_document: nil,
563
- options: nil,
564
- &block
565
- req = {
566
- document: document,
567
- update_mask: update_mask,
568
- mask: mask,
569
- current_document: current_document
570
- }.delete_if { |_, v| v.nil? }
571
- req = Google::Gax::to_proto(req, Google::Firestore::V1::UpdateDocumentRequest)
572
- @update_document.call(req, options, &block)
573
- end
574
-
575
- # Deletes a document.
576
- #
577
- # @param name [String]
578
- # Required. The resource name of the Document to delete. In the format:
579
- # `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
580
- # @param current_document [Google::Firestore::V1::Precondition | Hash]
581
- # An optional precondition on the document.
582
- # The request will fail if this is set and not met by the target document.
583
- # A hash of the same form as `Google::Firestore::V1::Precondition`
584
- # can also be provided.
585
- # @param options [Google::Gax::CallOptions]
586
- # Overrides the default settings for this call, e.g, timeout,
587
- # retries, etc.
588
- # @yield [result, operation] Access the result along with the RPC operation
589
- # @yieldparam result []
590
- # @yieldparam operation [GRPC::ActiveCall::Operation]
591
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
592
- # @example
593
- # require "google/cloud/firestore/v1"
594
- #
595
- # firestore_client = Google::Cloud::Firestore::V1.new
596
- #
597
- # # TODO: Initialize `name`:
598
- # name = ''
599
- # firestore_client.delete_document(name)
600
-
601
- def delete_document \
602
- name,
603
- current_document: nil,
604
- options: nil,
605
- &block
606
- req = {
607
- name: name,
608
- current_document: current_document
609
- }.delete_if { |_, v| v.nil? }
610
- req = Google::Gax::to_proto(req, Google::Firestore::V1::DeleteDocumentRequest)
611
- @delete_document.call(req, options, &block)
612
- nil
613
- end
614
-
615
- # Gets multiple documents.
616
- #
617
- # Documents returned by this method are not guaranteed to be returned in the
618
- # same order that they were requested.
619
- #
620
- # @param database [String]
621
- # Required. The database name. In the format:
622
- # `projects/{project_id}/databases/{database_id}`.
623
- # @param documents [Array<String>]
624
- # The names of the documents to retrieve. In the format:
625
- # `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
626
- # The request will fail if any of the document is not a child resource of the
627
- # given `database`. Duplicate names will be elided.
628
- # @param mask [Google::Firestore::V1::DocumentMask | Hash]
629
- # The fields to return. If not set, returns all fields.
630
- #
631
- # If a document has a field that is not present in this mask, that field will
632
- # not be returned in the response.
633
- # A hash of the same form as `Google::Firestore::V1::DocumentMask`
634
- # can also be provided.
635
- # @param transaction [String]
636
- # Reads documents in a transaction.
637
- # @param new_transaction [Google::Firestore::V1::TransactionOptions | Hash]
638
- # Starts a new transaction and reads the documents.
639
- # Defaults to a read-only transaction.
640
- # The new transaction ID will be returned as the first response in the
641
- # stream.
642
- # A hash of the same form as `Google::Firestore::V1::TransactionOptions`
643
- # can also be provided.
644
- # @param read_time [Google::Protobuf::Timestamp | Hash]
645
- # Reads documents as they were at the given time.
646
- # This may not be older than 60 seconds.
647
- # A hash of the same form as `Google::Protobuf::Timestamp`
648
- # can also be provided.
649
- # @param options [Google::Gax::CallOptions]
650
- # Overrides the default settings for this call, e.g, timeout,
651
- # retries, etc.
652
- # @return [Enumerable<Google::Firestore::V1::BatchGetDocumentsResponse>]
653
- # An enumerable of Google::Firestore::V1::BatchGetDocumentsResponse instances.
654
- #
655
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
656
- # @example
657
- # require "google/cloud/firestore/v1"
658
- #
659
- # firestore_client = Google::Cloud::Firestore::V1.new
660
- #
661
- # # TODO: Initialize `database`:
662
- # database = ''
663
- # firestore_client.batch_get_documents(database).each do |element|
664
- # # Process element.
665
- # end
666
-
667
- def batch_get_documents \
668
- database,
669
- documents: nil,
670
- mask: nil,
671
- transaction: nil,
672
- new_transaction: nil,
673
- read_time: nil,
674
- options: nil
675
- req = {
676
- database: database,
677
- documents: documents,
678
- mask: mask,
679
- transaction: transaction,
680
- new_transaction: new_transaction,
681
- read_time: read_time
682
- }.delete_if { |_, v| v.nil? }
683
- req = Google::Gax::to_proto(req, Google::Firestore::V1::BatchGetDocumentsRequest)
684
- @batch_get_documents.call(req, options)
685
- end
686
-
687
- # Starts a new transaction.
688
- #
689
- # @param database [String]
690
- # Required. The database name. In the format:
691
- # `projects/{project_id}/databases/{database_id}`.
692
- # @param options_ [Google::Firestore::V1::TransactionOptions | Hash]
693
- # The options for the transaction.
694
- # Defaults to a read-write transaction.
695
- # A hash of the same form as `Google::Firestore::V1::TransactionOptions`
696
- # can also be provided.
697
- # @param options [Google::Gax::CallOptions]
698
- # Overrides the default settings for this call, e.g, timeout,
699
- # retries, etc.
700
- # @yield [result, operation] Access the result along with the RPC operation
701
- # @yieldparam result [Google::Firestore::V1::BeginTransactionResponse]
702
- # @yieldparam operation [GRPC::ActiveCall::Operation]
703
- # @return [Google::Firestore::V1::BeginTransactionResponse]
704
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
705
- # @example
706
- # require "google/cloud/firestore/v1"
707
- #
708
- # firestore_client = Google::Cloud::Firestore::V1.new
709
- #
710
- # # TODO: Initialize `database`:
711
- # database = ''
712
- # response = firestore_client.begin_transaction(database)
713
-
714
- def begin_transaction \
715
- database,
716
- options_: nil,
717
- options: nil,
718
- &block
719
- req = {
720
- database: database,
721
- options: options_
722
- }.delete_if { |_, v| v.nil? }
723
- req = Google::Gax::to_proto(req, Google::Firestore::V1::BeginTransactionRequest)
724
- @begin_transaction.call(req, options, &block)
725
- end
726
-
727
- # Commits a transaction, while optionally updating documents.
728
- #
729
- # @param database [String]
730
- # Required. The database name. In the format:
731
- # `projects/{project_id}/databases/{database_id}`.
732
- # @param writes [Array<Google::Firestore::V1::Write | Hash>]
733
- # The writes to apply.
734
- #
735
- # Always executed atomically and in order.
736
- # A hash of the same form as `Google::Firestore::V1::Write`
737
- # can also be provided.
738
- # @param transaction [String]
739
- # If set, applies all writes in this transaction, and commits it.
740
- # @param options [Google::Gax::CallOptions]
741
- # Overrides the default settings for this call, e.g, timeout,
742
- # retries, etc.
743
- # @yield [result, operation] Access the result along with the RPC operation
744
- # @yieldparam result [Google::Firestore::V1::CommitResponse]
745
- # @yieldparam operation [GRPC::ActiveCall::Operation]
746
- # @return [Google::Firestore::V1::CommitResponse]
747
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
748
- # @example
749
- # require "google/cloud/firestore/v1"
750
- #
751
- # firestore_client = Google::Cloud::Firestore::V1.new
752
- #
753
- # # TODO: Initialize `database`:
754
- # database = ''
755
- # response = firestore_client.commit(database)
756
-
757
- def commit \
758
- database,
759
- writes: nil,
760
- transaction: nil,
761
- options: nil,
762
- &block
763
- req = {
764
- database: database,
765
- writes: writes,
766
- transaction: transaction
767
- }.delete_if { |_, v| v.nil? }
768
- req = Google::Gax::to_proto(req, Google::Firestore::V1::CommitRequest)
769
- @commit.call(req, options, &block)
770
- end
771
-
772
- # Rolls back a transaction.
773
- #
774
- # @param database [String]
775
- # Required. The database name. In the format:
776
- # `projects/{project_id}/databases/{database_id}`.
777
- # @param transaction [String]
778
- # Required. The transaction to roll back.
779
- # @param options [Google::Gax::CallOptions]
780
- # Overrides the default settings for this call, e.g, timeout,
781
- # retries, etc.
782
- # @yield [result, operation] Access the result along with the RPC operation
783
- # @yieldparam result []
784
- # @yieldparam operation [GRPC::ActiveCall::Operation]
785
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
786
- # @example
787
- # require "google/cloud/firestore/v1"
788
- #
789
- # firestore_client = Google::Cloud::Firestore::V1.new
790
- #
791
- # # TODO: Initialize `database`:
792
- # database = ''
793
- #
794
- # # TODO: Initialize `transaction`:
795
- # transaction = ''
796
- # firestore_client.rollback(database, transaction)
797
-
798
- def rollback \
799
- database,
800
- transaction,
801
- options: nil,
802
- &block
803
- req = {
804
- database: database,
805
- transaction: transaction
806
- }.delete_if { |_, v| v.nil? }
807
- req = Google::Gax::to_proto(req, Google::Firestore::V1::RollbackRequest)
808
- @rollback.call(req, options, &block)
809
- nil
810
- end
811
-
812
- # Runs a query.
813
- #
814
- # @param parent [String]
815
- # Required. The parent resource name. In the format:
816
- # `projects/{project_id}/databases/{database_id}/documents` or
817
- # `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
818
- # For example:
819
- # `projects/my-project/databases/my-database/documents` or
820
- # `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
821
- # @param structured_query [Google::Firestore::V1::StructuredQuery | Hash]
822
- # A structured query.
823
- # A hash of the same form as `Google::Firestore::V1::StructuredQuery`
824
- # can also be provided.
825
- # @param transaction [String]
826
- # Reads documents in a transaction.
827
- # @param new_transaction [Google::Firestore::V1::TransactionOptions | Hash]
828
- # Starts a new transaction and reads the documents.
829
- # Defaults to a read-only transaction.
830
- # The new transaction ID will be returned as the first response in the
831
- # stream.
832
- # A hash of the same form as `Google::Firestore::V1::TransactionOptions`
833
- # can also be provided.
834
- # @param read_time [Google::Protobuf::Timestamp | Hash]
835
- # Reads documents as they were at the given time.
836
- # This may not be older than 60 seconds.
837
- # A hash of the same form as `Google::Protobuf::Timestamp`
838
- # can also be provided.
839
- # @param options [Google::Gax::CallOptions]
840
- # Overrides the default settings for this call, e.g, timeout,
841
- # retries, etc.
842
- # @return [Enumerable<Google::Firestore::V1::RunQueryResponse>]
843
- # An enumerable of Google::Firestore::V1::RunQueryResponse instances.
844
- #
845
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
846
- # @example
847
- # require "google/cloud/firestore/v1"
848
- #
849
- # firestore_client = Google::Cloud::Firestore::V1.new
850
- #
851
- # # TODO: Initialize `parent`:
852
- # parent = ''
853
- # firestore_client.run_query(parent).each do |element|
854
- # # Process element.
855
- # end
856
-
857
- def run_query \
858
- parent,
859
- structured_query: nil,
860
- transaction: nil,
861
- new_transaction: nil,
862
- read_time: nil,
863
- options: nil
864
- req = {
865
- parent: parent,
866
- structured_query: structured_query,
867
- transaction: transaction,
868
- new_transaction: new_transaction,
869
- read_time: read_time
870
- }.delete_if { |_, v| v.nil? }
871
- req = Google::Gax::to_proto(req, Google::Firestore::V1::RunQueryRequest)
872
- @run_query.call(req, options)
873
- end
874
-
875
- # Streams batches of document updates and deletes, in order.
876
- #
877
- # @param reqs [Enumerable<Google::Firestore::V1::WriteRequest>]
878
- # The input requests.
879
- # @param options [Google::Gax::CallOptions]
880
- # Overrides the default settings for this call, e.g, timeout,
881
- # retries, etc.
882
- # @return [Enumerable<Google::Firestore::V1::WriteResponse>]
883
- # An enumerable of Google::Firestore::V1::WriteResponse instances.
884
- #
885
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
886
- #
887
- # @note
888
- # EXPERIMENTAL:
889
- # Streaming requests are still undergoing review.
890
- # This method interface might change in the future.
891
- #
892
- # @example
893
- # require "google/cloud/firestore/v1"
894
- #
895
- # firestore_client = Google::Cloud::Firestore::V1.new
896
- #
897
- # # TODO: Initialize `database`:
898
- # database = ''
899
- # request = { database: database }
900
- # requests = [request]
901
- # firestore_client.write(requests).each do |element|
902
- # # Process element.
903
- # end
904
-
905
- def write reqs, options: nil
906
- request_protos = reqs.lazy.map do |req|
907
- Google::Gax::to_proto(req, Google::Firestore::V1::WriteRequest)
908
- end
909
- @write.call(request_protos, options)
910
- end
911
-
912
- # Listens to changes.
913
- #
914
- # @param reqs [Enumerable<Google::Firestore::V1::ListenRequest>]
915
- # The input requests.
916
- # @param options [Google::Gax::CallOptions]
917
- # Overrides the default settings for this call, e.g, timeout,
918
- # retries, etc.
919
- # @return [Enumerable<Google::Firestore::V1::ListenResponse>]
920
- # An enumerable of Google::Firestore::V1::ListenResponse instances.
921
- #
922
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
923
- #
924
- # @note
925
- # EXPERIMENTAL:
926
- # Streaming requests are still undergoing review.
927
- # This method interface might change in the future.
928
- #
929
- # @example
930
- # require "google/cloud/firestore/v1"
931
- #
932
- # firestore_client = Google::Cloud::Firestore::V1.new
933
- #
934
- # # TODO: Initialize `database`:
935
- # database = ''
936
- # request = { database: database }
937
- # requests = [request]
938
- # firestore_client.listen(requests).each do |element|
939
- # # Process element.
940
- # end
941
-
942
- def listen reqs, options: nil
943
- request_protos = reqs.lazy.map do |req|
944
- Google::Gax::to_proto(req, Google::Firestore::V1::ListenRequest)
945
- end
946
- @listen.call(request_protos, options)
947
- end
948
-
949
- # Lists all the collection IDs underneath a document.
950
- #
951
- # @param parent [String]
952
- # Required. The parent document. In the format:
953
- # `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
954
- # For example:
955
- # `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
956
- # @param page_size [Integer]
957
- # The maximum number of resources contained in the underlying API
958
- # response. If page streaming is performed per-resource, this
959
- # parameter does not affect the return value. If page streaming is
960
- # performed per-page, this determines the maximum number of
961
- # resources in a page.
962
- # @param options [Google::Gax::CallOptions]
963
- # Overrides the default settings for this call, e.g, timeout,
964
- # retries, etc.
965
- # @yield [result, operation] Access the result along with the RPC operation
966
- # @yieldparam result [Google::Gax::PagedEnumerable<String>]
967
- # @yieldparam operation [GRPC::ActiveCall::Operation]
968
- # @return [Google::Gax::PagedEnumerable<String>]
969
- # An enumerable of String instances.
970
- # See Google::Gax::PagedEnumerable documentation for other
971
- # operations such as per-page iteration or access to the response
972
- # object.
973
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
974
- # @example
975
- # require "google/cloud/firestore/v1"
976
- #
977
- # firestore_client = Google::Cloud::Firestore::V1.new
978
- #
979
- # # TODO: Initialize `parent`:
980
- # parent = ''
981
- #
982
- # # Iterate over all results.
983
- # firestore_client.list_collection_ids(parent).each do |element|
984
- # # Process element.
985
- # end
986
- #
987
- # # Or iterate over results one page at a time.
988
- # firestore_client.list_collection_ids(parent).each_page do |page|
989
- # # Process each page at a time.
990
- # page.each do |element|
991
- # # Process element.
992
- # end
993
- # end
994
-
995
- def list_collection_ids \
996
- parent,
997
- page_size: nil,
998
- options: nil,
999
- &block
1000
- req = {
1001
- parent: parent,
1002
- page_size: page_size
1003
- }.delete_if { |_, v| v.nil? }
1004
- req = Google::Gax::to_proto(req, Google::Firestore::V1::ListCollectionIdsRequest)
1005
- @list_collection_ids.call(req, options, &block)
1006
- end
1007
- end
1008
- end
1009
- end
1010
- end
1011
- end