google-cloud-firestore 1.4.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
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,1021 +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/v1beta1/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/v1beta1/firestore_pb"
29
- require "google/cloud/firestore/v1beta1/credentials"
30
- require "google/cloud/firestore/version"
31
-
32
- module Google
33
- module Cloud
34
- module Firestore
35
- module V1beta1
36
- # @deprecated Use Google::Cloud::Firestore::V1::FirestoreClient instead.
37
- #
38
- # The Cloud Firestore service.
39
- #
40
- # This service exposes several types of comparable timestamps:
41
- #
42
- # * `create_time` - The time at which a document was created. Changes only
43
- # when a document is deleted, then re-created. Increases in a strict
44
- # monotonic fashion.
45
- # * `update_time` - The time at which a document was last updated. Changes
46
- # every time a document is modified. Does not change when a write results
47
- # in no modifications. Increases in a strict monotonic fashion.
48
- # * `read_time` - The time at which a particular state was observed. Used
49
- # to denote a consistent snapshot of the database or the time at which a
50
- # Document was observed to not exist.
51
- # * `commit_time` - The time at which the writes in a transaction were
52
- # committed. Any read with an equal or greater `read_time` is guaranteed
53
- # to see the effects of the transaction.
54
- #
55
- # @!attribute [r] firestore_stub
56
- # @return [Google::Firestore::V1beta1::Firestore::Stub]
57
- class FirestoreClient
58
- # @private
59
- attr_reader :firestore_stub
60
-
61
- # The default address of the service.
62
- SERVICE_ADDRESS = "firestore.googleapis.com".freeze
63
-
64
- # The default port of the service.
65
- DEFAULT_SERVICE_PORT = 443
66
-
67
- # The default set of gRPC interceptors.
68
- GRPC_INTERCEPTORS = []
69
-
70
- DEFAULT_TIMEOUT = 30
71
-
72
- PAGE_DESCRIPTORS = {
73
- "list_collection_ids" => Google::Gax::PageDescriptor.new(
74
- "page_token",
75
- "next_page_token",
76
- "collection_ids"),
77
- "list_documents" => Google::Gax::PageDescriptor.new(
78
- "page_token",
79
- "next_page_token",
80
- "documents")
81
- }.freeze
82
-
83
- private_constant :PAGE_DESCRIPTORS
84
-
85
- # The scopes needed to make gRPC calls to all of the methods defined in
86
- # this service.
87
- ALL_SCOPES = [
88
- "https://www.googleapis.com/auth/cloud-platform",
89
- "https://www.googleapis.com/auth/datastore"
90
- ].freeze
91
-
92
-
93
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
94
- # Provides the means for authenticating requests made by the client. This parameter can
95
- # be many types.
96
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
97
- # authenticating requests made by this client.
98
- # A `String` will be treated as the path to the keyfile to be used for the construction of
99
- # credentials for this client.
100
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
101
- # credentials for this client.
102
- # A `GRPC::Core::Channel` will be used to make calls through.
103
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
104
- # should already be composed with a `GRPC::Core::CallCredentials` object.
105
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
106
- # metadata for requests, generally, to give OAuth credentials.
107
- # @param scopes [Array<String>]
108
- # The OAuth scopes for this service. This parameter is ignored if
109
- # an updater_proc is supplied.
110
- # @param client_config [Hash]
111
- # A Hash for call options for each method. See
112
- # Google::Gax#construct_settings for the structure of
113
- # this data. Falls back to the default config if not specified
114
- # or the specified config is missing data points.
115
- # @param timeout [Numeric]
116
- # The default timeout, in seconds, for calls made through this client.
117
- # @param metadata [Hash]
118
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
119
- # @param service_address [String]
120
- # Override for the service hostname, or `nil` to leave as the default.
121
- # @param service_port [Integer]
122
- # Override for the service port, or `nil` to leave as the default.
123
- # @param exception_transformer [Proc]
124
- # An optional proc that intercepts any exceptions raised during an API call to inject
125
- # custom error handling.
126
- def initialize \
127
- credentials: nil,
128
- scopes: ALL_SCOPES,
129
- client_config: {},
130
- timeout: DEFAULT_TIMEOUT,
131
- metadata: nil,
132
- service_address: nil,
133
- service_port: nil,
134
- exception_transformer: nil,
135
- lib_name: nil,
136
- lib_version: ""
137
- # These require statements are intentionally placed here to initialize
138
- # the gRPC module only when it's required.
139
- # See https://github.com/googleapis/toolkit/issues/446
140
- require "google/gax/grpc"
141
- require "google/firestore/v1beta1/firestore_services_pb"
142
-
143
- credentials ||= Google::Cloud::Firestore::V1beta1::Credentials.default
144
-
145
- if credentials.is_a?(String) || credentials.is_a?(Hash)
146
- updater_proc = Google::Cloud::Firestore::V1beta1::Credentials.new(credentials).updater_proc
147
- end
148
- if credentials.is_a?(GRPC::Core::Channel)
149
- channel = credentials
150
- end
151
- if credentials.is_a?(GRPC::Core::ChannelCredentials)
152
- chan_creds = credentials
153
- end
154
- if credentials.is_a?(Proc)
155
- updater_proc = credentials
156
- end
157
- if credentials.is_a?(Google::Auth::Credentials)
158
- updater_proc = credentials.updater_proc
159
- end
160
-
161
- package_version = Google::Cloud::Firestore::VERSION
162
-
163
- google_api_client = "gl-ruby/#{RUBY_VERSION}"
164
- google_api_client << " #{lib_name}/#{lib_version}" if lib_name
165
- google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
166
- google_api_client << " grpc/#{GRPC::VERSION}"
167
- google_api_client.freeze
168
-
169
- headers = { :"x-goog-api-client" => google_api_client }
170
- if credentials.respond_to?(:quota_project_id) && credentials.quota_project_id
171
- headers[:"x-goog-user-project"] = credentials.quota_project_id
172
- end
173
- headers.merge!(metadata) unless metadata.nil?
174
- client_config_file = Pathname.new(__dir__).join(
175
- "firestore_client_config.json"
176
- )
177
- defaults = client_config_file.open do |f|
178
- Google::Gax.construct_settings(
179
- "google.firestore.v1beta1.Firestore",
180
- JSON.parse(f.read),
181
- client_config,
182
- Google::Gax::Grpc::STATUS_CODE_NAMES,
183
- timeout,
184
- page_descriptors: PAGE_DESCRIPTORS,
185
- errors: Google::Gax::Grpc::API_ERRORS,
186
- metadata: headers
187
- )
188
- end
189
-
190
- # Allow overriding the service path/port in subclasses.
191
- service_path = service_address || self.class::SERVICE_ADDRESS
192
- port = service_port || self.class::DEFAULT_SERVICE_PORT
193
- interceptors = self.class::GRPC_INTERCEPTORS
194
- @firestore_stub = Google::Gax::Grpc.create_stub(
195
- service_path,
196
- port,
197
- chan_creds: chan_creds,
198
- channel: channel,
199
- updater_proc: updater_proc,
200
- scopes: scopes,
201
- interceptors: interceptors,
202
- &Google::Firestore::V1beta1::Firestore::Stub.method(:new)
203
- )
204
-
205
- @delete_document = Google::Gax.create_api_call(
206
- @firestore_stub.method(:delete_document),
207
- defaults["delete_document"],
208
- exception_transformer: exception_transformer,
209
- params_extractor: proc do |request|
210
- {'name' => request.name}
211
- end
212
- )
213
- @batch_get_documents = Google::Gax.create_api_call(
214
- @firestore_stub.method(:batch_get_documents),
215
- defaults["batch_get_documents"],
216
- exception_transformer: exception_transformer,
217
- params_extractor: proc do |request|
218
- {'database' => request.database}
219
- end
220
- )
221
- @begin_transaction = Google::Gax.create_api_call(
222
- @firestore_stub.method(:begin_transaction),
223
- defaults["begin_transaction"],
224
- exception_transformer: exception_transformer,
225
- params_extractor: proc do |request|
226
- {'database' => request.database}
227
- end
228
- )
229
- @rollback = Google::Gax.create_api_call(
230
- @firestore_stub.method(:rollback),
231
- defaults["rollback"],
232
- exception_transformer: exception_transformer,
233
- params_extractor: proc do |request|
234
- {'database' => request.database}
235
- end
236
- )
237
- @run_query = Google::Gax.create_api_call(
238
- @firestore_stub.method(:run_query),
239
- defaults["run_query"],
240
- exception_transformer: exception_transformer,
241
- params_extractor: proc do |request|
242
- {'parent' => request.parent}
243
- end
244
- )
245
- @write = Google::Gax.create_api_call(
246
- @firestore_stub.method(:write),
247
- defaults["write"],
248
- exception_transformer: exception_transformer
249
- )
250
- @listen = Google::Gax.create_api_call(
251
- @firestore_stub.method(:listen),
252
- defaults["listen"],
253
- exception_transformer: exception_transformer
254
- )
255
- @list_collection_ids = Google::Gax.create_api_call(
256
- @firestore_stub.method(:list_collection_ids),
257
- defaults["list_collection_ids"],
258
- exception_transformer: exception_transformer,
259
- params_extractor: proc do |request|
260
- {'parent' => request.parent}
261
- end
262
- )
263
- @get_document = Google::Gax.create_api_call(
264
- @firestore_stub.method(:get_document),
265
- defaults["get_document"],
266
- exception_transformer: exception_transformer,
267
- params_extractor: proc do |request|
268
- {'name' => request.name}
269
- end
270
- )
271
- @list_documents = Google::Gax.create_api_call(
272
- @firestore_stub.method(:list_documents),
273
- defaults["list_documents"],
274
- exception_transformer: exception_transformer
275
- )
276
- @create_document = Google::Gax.create_api_call(
277
- @firestore_stub.method(:create_document),
278
- defaults["create_document"],
279
- exception_transformer: exception_transformer
280
- )
281
- @update_document = Google::Gax.create_api_call(
282
- @firestore_stub.method(:update_document),
283
- defaults["update_document"],
284
- exception_transformer: exception_transformer,
285
- params_extractor: proc do |request|
286
- {'document.name' => request.document.name}
287
- end
288
- )
289
- @commit = Google::Gax.create_api_call(
290
- @firestore_stub.method(:commit),
291
- defaults["commit"],
292
- exception_transformer: exception_transformer,
293
- params_extractor: proc do |request|
294
- {'database' => request.database}
295
- end
296
- )
297
- end
298
-
299
- # Service calls
300
-
301
- # Deletes a document.
302
- #
303
- # @param name [String]
304
- # Required. The resource name of the Document to delete. In the format:
305
- # `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
306
- # @param current_document [Google::Firestore::V1beta1::Precondition | Hash]
307
- # An optional precondition on the document.
308
- # The request will fail if this is set and not met by the target document.
309
- # A hash of the same form as `Google::Firestore::V1beta1::Precondition`
310
- # can also be provided.
311
- # @param options [Google::Gax::CallOptions]
312
- # Overrides the default settings for this call, e.g, timeout,
313
- # retries, etc.
314
- # @yield [result, operation] Access the result along with the RPC operation
315
- # @yieldparam result []
316
- # @yieldparam operation [GRPC::ActiveCall::Operation]
317
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
318
- # @example
319
- # require "google/cloud/firestore/v1beta1"
320
- #
321
- # firestore_client = Google::Cloud::Firestore::V1beta1.new
322
- #
323
- # # TODO: Initialize `name`:
324
- # name = ''
325
- # firestore_client.delete_document(name)
326
-
327
- def delete_document \
328
- name,
329
- current_document: nil,
330
- options: nil,
331
- &block
332
- req = {
333
- name: name,
334
- current_document: current_document
335
- }.delete_if { |_, v| v.nil? }
336
- req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::DeleteDocumentRequest)
337
- @delete_document.call(req, options, &block)
338
- nil
339
- end
340
-
341
- # Gets multiple documents.
342
- #
343
- # Documents returned by this method are not guaranteed to be returned in the
344
- # same order that they were requested.
345
- #
346
- # @param database [String]
347
- # Required. The database name. In the format:
348
- # `projects/{project_id}/databases/{database_id}`.
349
- # @param documents [Array<String>]
350
- # The names of the documents to retrieve. In the format:
351
- # `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
352
- # The request will fail if any of the document is not a child resource of the
353
- # given `database`. Duplicate names will be elided.
354
- # @param mask [Google::Firestore::V1beta1::DocumentMask | Hash]
355
- # The fields to return. If not set, returns all fields.
356
- #
357
- # If a document has a field that is not present in this mask, that field will
358
- # not be returned in the response.
359
- # A hash of the same form as `Google::Firestore::V1beta1::DocumentMask`
360
- # can also be provided.
361
- # @param transaction [String]
362
- # Reads documents in a transaction.
363
- # @param new_transaction [Google::Firestore::V1beta1::TransactionOptions | Hash]
364
- # Starts a new transaction and reads the documents.
365
- # Defaults to a read-only transaction.
366
- # The new transaction ID will be returned as the first response in the
367
- # stream.
368
- # A hash of the same form as `Google::Firestore::V1beta1::TransactionOptions`
369
- # can also be provided.
370
- # @param read_time [Google::Protobuf::Timestamp | Hash]
371
- # Reads documents as they were at the given time.
372
- # This may not be older than 60 seconds.
373
- # A hash of the same form as `Google::Protobuf::Timestamp`
374
- # can also be provided.
375
- # @param options [Google::Gax::CallOptions]
376
- # Overrides the default settings for this call, e.g, timeout,
377
- # retries, etc.
378
- # @return [Enumerable<Google::Firestore::V1beta1::BatchGetDocumentsResponse>]
379
- # An enumerable of Google::Firestore::V1beta1::BatchGetDocumentsResponse instances.
380
- #
381
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
382
- # @example
383
- # require "google/cloud/firestore/v1beta1"
384
- #
385
- # firestore_client = Google::Cloud::Firestore::V1beta1.new
386
- #
387
- # # TODO: Initialize `database`:
388
- # database = ''
389
- # firestore_client.batch_get_documents(database).each do |element|
390
- # # Process element.
391
- # end
392
-
393
- def batch_get_documents \
394
- database,
395
- documents: nil,
396
- mask: nil,
397
- transaction: nil,
398
- new_transaction: nil,
399
- read_time: nil,
400
- options: nil
401
- req = {
402
- database: database,
403
- documents: documents,
404
- mask: mask,
405
- transaction: transaction,
406
- new_transaction: new_transaction,
407
- read_time: read_time
408
- }.delete_if { |_, v| v.nil? }
409
- req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::BatchGetDocumentsRequest)
410
- @batch_get_documents.call(req, options)
411
- end
412
-
413
- # Starts a new transaction.
414
- #
415
- # @param database [String]
416
- # Required. The database name. In the format:
417
- # `projects/{project_id}/databases/{database_id}`.
418
- # @param options_ [Google::Firestore::V1beta1::TransactionOptions | Hash]
419
- # The options for the transaction.
420
- # Defaults to a read-write transaction.
421
- # A hash of the same form as `Google::Firestore::V1beta1::TransactionOptions`
422
- # can also be provided.
423
- # @param options [Google::Gax::CallOptions]
424
- # Overrides the default settings for this call, e.g, timeout,
425
- # retries, etc.
426
- # @yield [result, operation] Access the result along with the RPC operation
427
- # @yieldparam result [Google::Firestore::V1beta1::BeginTransactionResponse]
428
- # @yieldparam operation [GRPC::ActiveCall::Operation]
429
- # @return [Google::Firestore::V1beta1::BeginTransactionResponse]
430
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
431
- # @example
432
- # require "google/cloud/firestore/v1beta1"
433
- #
434
- # firestore_client = Google::Cloud::Firestore::V1beta1.new
435
- #
436
- # # TODO: Initialize `database`:
437
- # database = ''
438
- # response = firestore_client.begin_transaction(database)
439
-
440
- def begin_transaction \
441
- database,
442
- options_: nil,
443
- options: nil,
444
- &block
445
- req = {
446
- database: database,
447
- options: options_
448
- }.delete_if { |_, v| v.nil? }
449
- req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::BeginTransactionRequest)
450
- @begin_transaction.call(req, options, &block)
451
- end
452
-
453
- # Rolls back a transaction.
454
- #
455
- # @param database [String]
456
- # Required. The database name. In the format:
457
- # `projects/{project_id}/databases/{database_id}`.
458
- # @param transaction [String]
459
- # Required. The transaction to roll back.
460
- # @param options [Google::Gax::CallOptions]
461
- # Overrides the default settings for this call, e.g, timeout,
462
- # retries, etc.
463
- # @yield [result, operation] Access the result along with the RPC operation
464
- # @yieldparam result []
465
- # @yieldparam operation [GRPC::ActiveCall::Operation]
466
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
467
- # @example
468
- # require "google/cloud/firestore/v1beta1"
469
- #
470
- # firestore_client = Google::Cloud::Firestore::V1beta1.new
471
- #
472
- # # TODO: Initialize `database`:
473
- # database = ''
474
- #
475
- # # TODO: Initialize `transaction`:
476
- # transaction = ''
477
- # firestore_client.rollback(database, transaction)
478
-
479
- def rollback \
480
- database,
481
- transaction,
482
- options: nil,
483
- &block
484
- req = {
485
- database: database,
486
- transaction: transaction
487
- }.delete_if { |_, v| v.nil? }
488
- req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::RollbackRequest)
489
- @rollback.call(req, options, &block)
490
- nil
491
- end
492
-
493
- # Runs a query.
494
- #
495
- # @param parent [String]
496
- # Required. The parent resource name. In the format:
497
- # `projects/{project_id}/databases/{database_id}/documents` or
498
- # `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
499
- # For example:
500
- # `projects/my-project/databases/my-database/documents` or
501
- # `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
502
- # @param structured_query [Google::Firestore::V1beta1::StructuredQuery | Hash]
503
- # A structured query.
504
- # A hash of the same form as `Google::Firestore::V1beta1::StructuredQuery`
505
- # can also be provided.
506
- # @param transaction [String]
507
- # Reads documents in a transaction.
508
- # @param new_transaction [Google::Firestore::V1beta1::TransactionOptions | Hash]
509
- # Starts a new transaction and reads the documents.
510
- # Defaults to a read-only transaction.
511
- # The new transaction ID will be returned as the first response in the
512
- # stream.
513
- # A hash of the same form as `Google::Firestore::V1beta1::TransactionOptions`
514
- # can also be provided.
515
- # @param read_time [Google::Protobuf::Timestamp | Hash]
516
- # Reads documents as they were at the given time.
517
- # This may not be older than 60 seconds.
518
- # A hash of the same form as `Google::Protobuf::Timestamp`
519
- # can also be provided.
520
- # @param options [Google::Gax::CallOptions]
521
- # Overrides the default settings for this call, e.g, timeout,
522
- # retries, etc.
523
- # @return [Enumerable<Google::Firestore::V1beta1::RunQueryResponse>]
524
- # An enumerable of Google::Firestore::V1beta1::RunQueryResponse instances.
525
- #
526
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
527
- # @example
528
- # require "google/cloud/firestore/v1beta1"
529
- #
530
- # firestore_client = Google::Cloud::Firestore::V1beta1.new
531
- #
532
- # # TODO: Initialize `parent`:
533
- # parent = ''
534
- # firestore_client.run_query(parent).each do |element|
535
- # # Process element.
536
- # end
537
-
538
- def run_query \
539
- parent,
540
- structured_query: nil,
541
- transaction: nil,
542
- new_transaction: nil,
543
- read_time: nil,
544
- options: nil
545
- req = {
546
- parent: parent,
547
- structured_query: structured_query,
548
- transaction: transaction,
549
- new_transaction: new_transaction,
550
- read_time: read_time
551
- }.delete_if { |_, v| v.nil? }
552
- req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::RunQueryRequest)
553
- @run_query.call(req, options)
554
- end
555
-
556
- # Streams batches of document updates and deletes, in order.
557
- #
558
- # @param reqs [Enumerable<Google::Firestore::V1beta1::WriteRequest>]
559
- # The input requests.
560
- # @param options [Google::Gax::CallOptions]
561
- # Overrides the default settings for this call, e.g, timeout,
562
- # retries, etc.
563
- # @return [Enumerable<Google::Firestore::V1beta1::WriteResponse>]
564
- # An enumerable of Google::Firestore::V1beta1::WriteResponse instances.
565
- #
566
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
567
- #
568
- # @note
569
- # EXPERIMENTAL:
570
- # Streaming requests are still undergoing review.
571
- # This method interface might change in the future.
572
- #
573
- # @example
574
- # require "google/cloud/firestore/v1beta1"
575
- #
576
- # firestore_client = Google::Cloud::Firestore::V1beta1.new
577
- #
578
- # # TODO: Initialize `database`:
579
- # database = ''
580
- # request = { database: database }
581
- # requests = [request]
582
- # firestore_client.write(requests).each do |element|
583
- # # Process element.
584
- # end
585
-
586
- def write reqs, options: nil
587
- request_protos = reqs.lazy.map do |req|
588
- Google::Gax::to_proto(req, Google::Firestore::V1beta1::WriteRequest)
589
- end
590
- @write.call(request_protos, options)
591
- end
592
-
593
- # Listens to changes.
594
- #
595
- # @param reqs [Enumerable<Google::Firestore::V1beta1::ListenRequest>]
596
- # The input requests.
597
- # @param options [Google::Gax::CallOptions]
598
- # Overrides the default settings for this call, e.g, timeout,
599
- # retries, etc.
600
- # @return [Enumerable<Google::Firestore::V1beta1::ListenResponse>]
601
- # An enumerable of Google::Firestore::V1beta1::ListenResponse instances.
602
- #
603
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
604
- #
605
- # @note
606
- # EXPERIMENTAL:
607
- # Streaming requests are still undergoing review.
608
- # This method interface might change in the future.
609
- #
610
- # @example
611
- # require "google/cloud/firestore/v1beta1"
612
- #
613
- # firestore_client = Google::Cloud::Firestore::V1beta1.new
614
- #
615
- # # TODO: Initialize `database`:
616
- # database = ''
617
- # request = { database: database }
618
- # requests = [request]
619
- # firestore_client.listen(requests).each do |element|
620
- # # Process element.
621
- # end
622
-
623
- def listen reqs, options: nil
624
- request_protos = reqs.lazy.map do |req|
625
- Google::Gax::to_proto(req, Google::Firestore::V1beta1::ListenRequest)
626
- end
627
- @listen.call(request_protos, options)
628
- end
629
-
630
- # Lists all the collection IDs underneath a document.
631
- #
632
- # @param parent [String]
633
- # Required. The parent document. In the format:
634
- # `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
635
- # For example:
636
- # `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
637
- # @param page_size [Integer]
638
- # The maximum number of resources contained in the underlying API
639
- # response. If page streaming is performed per-resource, this
640
- # parameter does not affect the return value. If page streaming is
641
- # performed per-page, this determines the maximum number of
642
- # resources in a page.
643
- # @param options [Google::Gax::CallOptions]
644
- # Overrides the default settings for this call, e.g, timeout,
645
- # retries, etc.
646
- # @yield [result, operation] Access the result along with the RPC operation
647
- # @yieldparam result [Google::Gax::PagedEnumerable<String>]
648
- # @yieldparam operation [GRPC::ActiveCall::Operation]
649
- # @return [Google::Gax::PagedEnumerable<String>]
650
- # An enumerable of String instances.
651
- # See Google::Gax::PagedEnumerable documentation for other
652
- # operations such as per-page iteration or access to the response
653
- # object.
654
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
655
- # @example
656
- # require "google/cloud/firestore/v1beta1"
657
- #
658
- # firestore_client = Google::Cloud::Firestore::V1beta1.new
659
- #
660
- # # TODO: Initialize `parent`:
661
- # parent = ''
662
- #
663
- # # Iterate over all results.
664
- # firestore_client.list_collection_ids(parent).each do |element|
665
- # # Process element.
666
- # end
667
- #
668
- # # Or iterate over results one page at a time.
669
- # firestore_client.list_collection_ids(parent).each_page do |page|
670
- # # Process each page at a time.
671
- # page.each do |element|
672
- # # Process element.
673
- # end
674
- # end
675
-
676
- def list_collection_ids \
677
- parent,
678
- page_size: nil,
679
- options: nil,
680
- &block
681
- req = {
682
- parent: parent,
683
- page_size: page_size
684
- }.delete_if { |_, v| v.nil? }
685
- req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::ListCollectionIdsRequest)
686
- @list_collection_ids.call(req, options, &block)
687
- end
688
-
689
- # Gets a single document.
690
- #
691
- # @param name [String]
692
- # Required. The resource name of the Document to get. In the format:
693
- # `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
694
- # @param mask [Google::Firestore::V1beta1::DocumentMask | Hash]
695
- # The fields to return. If not set, returns all fields.
696
- #
697
- # If the document has a field that is not present in this mask, that field
698
- # will not be returned in the response.
699
- # A hash of the same form as `Google::Firestore::V1beta1::DocumentMask`
700
- # can also be provided.
701
- # @param transaction [String]
702
- # Reads the document in a transaction.
703
- # @param read_time [Google::Protobuf::Timestamp | Hash]
704
- # Reads the version of the document at the given time.
705
- # This may not be older than 60 seconds.
706
- # A hash of the same form as `Google::Protobuf::Timestamp`
707
- # can also be provided.
708
- # @param options [Google::Gax::CallOptions]
709
- # Overrides the default settings for this call, e.g, timeout,
710
- # retries, etc.
711
- # @yield [result, operation] Access the result along with the RPC operation
712
- # @yieldparam result [Google::Firestore::V1beta1::Document]
713
- # @yieldparam operation [GRPC::ActiveCall::Operation]
714
- # @return [Google::Firestore::V1beta1::Document]
715
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
716
- # @example
717
- # require "google/cloud/firestore/v1beta1"
718
- #
719
- # firestore_client = Google::Cloud::Firestore::V1beta1.new
720
- #
721
- # # TODO: Initialize `name`:
722
- # name = ''
723
- # response = firestore_client.get_document(name)
724
-
725
- def get_document \
726
- name,
727
- mask: nil,
728
- transaction: nil,
729
- read_time: nil,
730
- options: nil,
731
- &block
732
- req = {
733
- name: name,
734
- mask: mask,
735
- transaction: transaction,
736
- read_time: read_time
737
- }.delete_if { |_, v| v.nil? }
738
- req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::GetDocumentRequest)
739
- @get_document.call(req, options, &block)
740
- end
741
-
742
- # Lists documents.
743
- #
744
- # @param parent [String]
745
- # Required. The parent resource name. In the format:
746
- # `projects/{project_id}/databases/{database_id}/documents` or
747
- # `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
748
- # For example:
749
- # `projects/my-project/databases/my-database/documents` or
750
- # `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
751
- # @param collection_id [String]
752
- # Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`
753
- # or `messages`.
754
- # @param page_size [Integer]
755
- # The maximum number of resources contained in the underlying API
756
- # response. If page streaming is performed per-resource, this
757
- # parameter does not affect the return value. If page streaming is
758
- # performed per-page, this determines the maximum number of
759
- # resources in a page.
760
- # @param order_by [String]
761
- # The order to sort results by. For example: `priority desc, name`.
762
- # @param mask [Google::Firestore::V1beta1::DocumentMask | Hash]
763
- # The fields to return. If not set, returns all fields.
764
- #
765
- # If a document has a field that is not present in this mask, that field
766
- # will not be returned in the response.
767
- # A hash of the same form as `Google::Firestore::V1beta1::DocumentMask`
768
- # can also be provided.
769
- # @param transaction [String]
770
- # Reads documents in a transaction.
771
- # @param read_time [Google::Protobuf::Timestamp | Hash]
772
- # Reads documents as they were at the given time.
773
- # This may not be older than 60 seconds.
774
- # A hash of the same form as `Google::Protobuf::Timestamp`
775
- # can also be provided.
776
- # @param show_missing [true, false]
777
- # If the list should show missing documents. A missing document is a
778
- # document that does not exist but has sub-documents. These documents will
779
- # be returned with a key but will not have fields, {Google::Firestore::V1beta1::Document#create_time Document#create_time},
780
- # or {Google::Firestore::V1beta1::Document#update_time Document#update_time} set.
781
- #
782
- # Requests with `show_missing` may not specify `where` or
783
- # `order_by`.
784
- # @param options [Google::Gax::CallOptions]
785
- # Overrides the default settings for this call, e.g, timeout,
786
- # retries, etc.
787
- # @yield [result, operation] Access the result along with the RPC operation
788
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Firestore::V1beta1::Document>]
789
- # @yieldparam operation [GRPC::ActiveCall::Operation]
790
- # @return [Google::Gax::PagedEnumerable<Google::Firestore::V1beta1::Document>]
791
- # An enumerable of Google::Firestore::V1beta1::Document instances.
792
- # See Google::Gax::PagedEnumerable documentation for other
793
- # operations such as per-page iteration or access to the response
794
- # object.
795
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
796
- # @example
797
- # require "google/cloud/firestore/v1beta1"
798
- #
799
- # firestore_client = Google::Cloud::Firestore::V1beta1.new
800
- #
801
- # # TODO: Initialize `parent`:
802
- # parent = ''
803
- #
804
- # # TODO: Initialize `collection_id`:
805
- # collection_id = ''
806
- #
807
- # # Iterate over all results.
808
- # firestore_client.list_documents(parent, collection_id).each do |element|
809
- # # Process element.
810
- # end
811
- #
812
- # # Or iterate over results one page at a time.
813
- # firestore_client.list_documents(parent, collection_id).each_page do |page|
814
- # # Process each page at a time.
815
- # page.each do |element|
816
- # # Process element.
817
- # end
818
- # end
819
-
820
- def list_documents \
821
- parent,
822
- collection_id,
823
- page_size: nil,
824
- order_by: nil,
825
- mask: nil,
826
- transaction: nil,
827
- read_time: nil,
828
- show_missing: nil,
829
- options: nil,
830
- &block
831
- req = {
832
- parent: parent,
833
- collection_id: collection_id,
834
- page_size: page_size,
835
- order_by: order_by,
836
- mask: mask,
837
- transaction: transaction,
838
- read_time: read_time,
839
- show_missing: show_missing
840
- }.delete_if { |_, v| v.nil? }
841
- req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::ListDocumentsRequest)
842
- @list_documents.call(req, options, &block)
843
- end
844
-
845
- # Creates a new document.
846
- #
847
- # @param parent [String]
848
- # Required. The parent resource. For example:
849
- # `projects/{project_id}/databases/{database_id}/documents` or
850
- # `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}`
851
- # @param collection_id [String]
852
- # Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`.
853
- # @param document [Google::Firestore::V1beta1::Document | Hash]
854
- # Required. The document to create. `name` must not be set.
855
- # A hash of the same form as `Google::Firestore::V1beta1::Document`
856
- # can also be provided.
857
- # @param document_id [String]
858
- # The client-assigned document ID to use for this document.
859
- #
860
- # Optional. If not specified, an ID will be assigned by the service.
861
- # @param mask [Google::Firestore::V1beta1::DocumentMask | Hash]
862
- # The fields to return. If not set, returns all fields.
863
- #
864
- # If the document has a field that is not present in this mask, that field
865
- # will not be returned in the response.
866
- # A hash of the same form as `Google::Firestore::V1beta1::DocumentMask`
867
- # can also be provided.
868
- # @param options [Google::Gax::CallOptions]
869
- # Overrides the default settings for this call, e.g, timeout,
870
- # retries, etc.
871
- # @yield [result, operation] Access the result along with the RPC operation
872
- # @yieldparam result [Google::Firestore::V1beta1::Document]
873
- # @yieldparam operation [GRPC::ActiveCall::Operation]
874
- # @return [Google::Firestore::V1beta1::Document]
875
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
876
- # @example
877
- # require "google/cloud/firestore/v1beta1"
878
- #
879
- # firestore_client = Google::Cloud::Firestore::V1beta1.new
880
- #
881
- # # TODO: Initialize `parent`:
882
- # parent = ''
883
- #
884
- # # TODO: Initialize `collection_id`:
885
- # collection_id = ''
886
- #
887
- # # TODO: Initialize `document`:
888
- # document = {}
889
- # response = firestore_client.create_document(parent, collection_id, document)
890
-
891
- def create_document \
892
- parent,
893
- collection_id,
894
- document,
895
- document_id: nil,
896
- mask: nil,
897
- options: nil,
898
- &block
899
- req = {
900
- parent: parent,
901
- collection_id: collection_id,
902
- document: document,
903
- document_id: document_id,
904
- mask: mask
905
- }.delete_if { |_, v| v.nil? }
906
- req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::CreateDocumentRequest)
907
- @create_document.call(req, options, &block)
908
- end
909
-
910
- # Updates or inserts a document.
911
- #
912
- # @param document [Google::Firestore::V1beta1::Document | Hash]
913
- # Required. The updated document.
914
- # Creates the document if it does not already exist.
915
- # A hash of the same form as `Google::Firestore::V1beta1::Document`
916
- # can also be provided.
917
- # @param update_mask [Google::Firestore::V1beta1::DocumentMask | Hash]
918
- # The fields to update.
919
- # None of the field paths in the mask may contain a reserved name.
920
- #
921
- # If the document exists on the server and has fields not referenced in the
922
- # mask, they are left unchanged.
923
- # Fields referenced in the mask, but not present in the input document, are
924
- # deleted from the document on the server.
925
- # A hash of the same form as `Google::Firestore::V1beta1::DocumentMask`
926
- # can also be provided.
927
- # @param mask [Google::Firestore::V1beta1::DocumentMask | Hash]
928
- # The fields to return. If not set, returns all fields.
929
- #
930
- # If the document has a field that is not present in this mask, that field
931
- # will not be returned in the response.
932
- # A hash of the same form as `Google::Firestore::V1beta1::DocumentMask`
933
- # can also be provided.
934
- # @param current_document [Google::Firestore::V1beta1::Precondition | Hash]
935
- # An optional precondition on the document.
936
- # The request will fail if this is set and not met by the target document.
937
- # A hash of the same form as `Google::Firestore::V1beta1::Precondition`
938
- # can also be provided.
939
- # @param options [Google::Gax::CallOptions]
940
- # Overrides the default settings for this call, e.g, timeout,
941
- # retries, etc.
942
- # @yield [result, operation] Access the result along with the RPC operation
943
- # @yieldparam result [Google::Firestore::V1beta1::Document]
944
- # @yieldparam operation [GRPC::ActiveCall::Operation]
945
- # @return [Google::Firestore::V1beta1::Document]
946
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
947
- # @example
948
- # require "google/cloud/firestore/v1beta1"
949
- #
950
- # firestore_client = Google::Cloud::Firestore::V1beta1.new
951
- #
952
- # # TODO: Initialize `document`:
953
- # document = {}
954
- # response = firestore_client.update_document(document)
955
-
956
- def update_document \
957
- document,
958
- update_mask: nil,
959
- mask: nil,
960
- current_document: nil,
961
- options: nil,
962
- &block
963
- req = {
964
- document: document,
965
- update_mask: update_mask,
966
- mask: mask,
967
- current_document: current_document
968
- }.delete_if { |_, v| v.nil? }
969
- req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::UpdateDocumentRequest)
970
- @update_document.call(req, options, &block)
971
- end
972
-
973
- # Commits a transaction, while optionally updating documents.
974
- #
975
- # @param database [String]
976
- # Required. The database name. In the format:
977
- # `projects/{project_id}/databases/{database_id}`.
978
- # @param writes [Array<Google::Firestore::V1beta1::Write | Hash>]
979
- # The writes to apply.
980
- #
981
- # Always executed atomically and in order.
982
- # A hash of the same form as `Google::Firestore::V1beta1::Write`
983
- # can also be provided.
984
- # @param transaction [String]
985
- # If set, applies all writes in this transaction, and commits it.
986
- # @param options [Google::Gax::CallOptions]
987
- # Overrides the default settings for this call, e.g, timeout,
988
- # retries, etc.
989
- # @yield [result, operation] Access the result along with the RPC operation
990
- # @yieldparam result [Google::Firestore::V1beta1::CommitResponse]
991
- # @yieldparam operation [GRPC::ActiveCall::Operation]
992
- # @return [Google::Firestore::V1beta1::CommitResponse]
993
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
994
- # @example
995
- # require "google/cloud/firestore/v1beta1"
996
- #
997
- # firestore_client = Google::Cloud::Firestore::V1beta1.new
998
- #
999
- # # TODO: Initialize `database`:
1000
- # database = ''
1001
- # response = firestore_client.commit(database)
1002
-
1003
- def commit \
1004
- database,
1005
- writes: nil,
1006
- transaction: nil,
1007
- options: nil,
1008
- &block
1009
- req = {
1010
- database: database,
1011
- writes: writes,
1012
- transaction: transaction
1013
- }.delete_if { |_, v| v.nil? }
1014
- req = Google::Gax::to_proto(req, Google::Firestore::V1beta1::CommitRequest)
1015
- @commit.call(req, options, &block)
1016
- end
1017
- end
1018
- end
1019
- end
1020
- end
1021
- end