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