google-cloud-firestore 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/LOGGING.md +1 -1
- data/lib/google-cloud-firestore.rb +1 -0
- data/lib/google/cloud/firestore.rb +9 -4
- data/lib/google/cloud/firestore/admin.rb +144 -0
- data/lib/google/cloud/firestore/admin/v1.rb +151 -0
- data/lib/google/cloud/firestore/admin/v1/credentials.rb +44 -0
- data/lib/google/cloud/firestore/admin/v1/doc/google/firestore/admin/v1/field.rb +88 -0
- data/lib/google/cloud/firestore/admin/v1/doc/google/firestore/admin/v1/firestore_admin.rb +161 -0
- data/lib/google/cloud/firestore/admin/v1/doc/google/firestore/admin/v1/index.rb +139 -0
- data/lib/google/cloud/firestore/admin/v1/doc/google/longrunning/operations.rb +51 -0
- data/lib/google/cloud/firestore/admin/v1/doc/google/protobuf/any.rb +131 -0
- data/lib/google/cloud/firestore/admin/v1/doc/google/protobuf/empty.rb +29 -0
- data/lib/google/cloud/firestore/admin/v1/doc/google/protobuf/field_mask.rb +222 -0
- data/lib/google/cloud/firestore/admin/v1/doc/google/rpc/status.rb +87 -0
- data/lib/google/cloud/firestore/admin/v1/firestore_admin_client.rb +761 -0
- data/lib/google/cloud/firestore/admin/v1/firestore_admin_client_config.json +71 -0
- data/lib/google/cloud/firestore/v1.rb +2 -2
- data/lib/google/cloud/firestore/v1beta1.rb +2 -2
- data/lib/google/cloud/firestore/version.rb +1 -1
- data/lib/google/firestore/admin/v1/field_pb.rb +31 -0
- data/lib/google/firestore/admin/v1/firestore_admin_pb.rb +81 -0
- data/lib/google/firestore/admin/v1/firestore_admin_services_pb.rb +94 -0
- data/lib/google/firestore/admin/v1/index_pb.rb +56 -0
- data/lib/google/firestore/admin/v1/location_pb.rb +22 -0
- data/lib/google/firestore/admin/v1/operation_pb.rb +90 -0
- metadata +22 -3
@@ -0,0 +1,29 @@
|
|
1
|
+
# Copyright 2019 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
|
@@ -0,0 +1,222 @@
|
|
1
|
+
# Copyright 2019 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
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# Copyright 2019 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). The error model is designed to be:
|
21
|
+
#
|
22
|
+
# * Simple to use and understand for most users
|
23
|
+
# * Flexible enough to meet unexpected needs
|
24
|
+
#
|
25
|
+
# = Overview
|
26
|
+
#
|
27
|
+
# The `Status` message contains three pieces of data: error code, error
|
28
|
+
# message, and error details. The error code should be an enum value of
|
29
|
+
# {Google::Rpc::Code}, but it may accept additional error codes
|
30
|
+
# if needed. The error message should be a developer-facing English message
|
31
|
+
# that helps developers *understand* and *resolve* the error. If a localized
|
32
|
+
# user-facing error message is needed, put the localized message in the error
|
33
|
+
# details or localize it in the client. The optional error details may contain
|
34
|
+
# arbitrary information about the error. There is a predefined set of error
|
35
|
+
# detail types in the package `google.rpc` that can be used for common error
|
36
|
+
# conditions.
|
37
|
+
#
|
38
|
+
# = Language mapping
|
39
|
+
#
|
40
|
+
# The `Status` message is the logical representation of the error model, but it
|
41
|
+
# is not necessarily the actual wire format. When the `Status` message is
|
42
|
+
# exposed in different client libraries and different wire protocols, it can be
|
43
|
+
# mapped differently. For example, it will likely be mapped to some exceptions
|
44
|
+
# in Java, but more likely mapped to some error codes in C.
|
45
|
+
#
|
46
|
+
# = Other uses
|
47
|
+
#
|
48
|
+
# The error model and the `Status` message can be used in a variety of
|
49
|
+
# environments, either with or without APIs, to provide a
|
50
|
+
# consistent developer experience across different environments.
|
51
|
+
#
|
52
|
+
# Example uses of this error model include:
|
53
|
+
#
|
54
|
+
# * Partial errors. If a service needs to return partial errors to the client,
|
55
|
+
# it may embed the `Status` in the normal response to indicate the partial
|
56
|
+
# errors.
|
57
|
+
#
|
58
|
+
# * Workflow errors. A typical workflow has multiple steps. Each step may
|
59
|
+
# have a `Status` message for error reporting.
|
60
|
+
#
|
61
|
+
# * Batch operations. If a client uses batch request and batch response, the
|
62
|
+
# `Status` message should be used directly inside batch response, one for
|
63
|
+
# each error sub-response.
|
64
|
+
#
|
65
|
+
# * Asynchronous operations. If an API call embeds asynchronous operation
|
66
|
+
# results in its response, the status of those operations should be
|
67
|
+
# represented directly using the `Status` message.
|
68
|
+
#
|
69
|
+
# * Logging. If some API errors are stored in logs, the message `Status` could
|
70
|
+
# be used directly after any stripping needed for security/privacy reasons.
|
71
|
+
# @!attribute [rw] code
|
72
|
+
# @return [Integer]
|
73
|
+
# The status code, which should be an enum value of
|
74
|
+
# {Google::Rpc::Code}.
|
75
|
+
# @!attribute [rw] message
|
76
|
+
# @return [String]
|
77
|
+
# A developer-facing error message, which should be in English. Any
|
78
|
+
# user-facing error message should be localized and sent in the
|
79
|
+
# {Google::Rpc::Status#details} field, or localized
|
80
|
+
# by the client.
|
81
|
+
# @!attribute [rw] details
|
82
|
+
# @return [Array<Google::Protobuf::Any>]
|
83
|
+
# A list of messages that carry the error details. There is a common set of
|
84
|
+
# message types for APIs to use.
|
85
|
+
class Status; end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,761 @@
|
|
1
|
+
# Copyright 2019 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
|
+
|
28
|
+
require "google/firestore/admin/v1/firestore_admin_pb"
|
29
|
+
require "google/cloud/firestore/admin/v1/credentials"
|
30
|
+
require "google/cloud/firestore/version"
|
31
|
+
|
32
|
+
module Google
|
33
|
+
module Cloud
|
34
|
+
module Firestore
|
35
|
+
module Admin
|
36
|
+
module V1
|
37
|
+
# Operations are created by service `FirestoreAdmin`, but are accessed via
|
38
|
+
# service `google.longrunning.Operations`.
|
39
|
+
#
|
40
|
+
# @!attribute [r] firestore_admin_stub
|
41
|
+
# @return [Google::Firestore::Admin::V1::FirestoreAdmin::Stub]
|
42
|
+
class FirestoreAdminClient
|
43
|
+
# @private
|
44
|
+
attr_reader :firestore_admin_stub
|
45
|
+
|
46
|
+
# The default address of the service.
|
47
|
+
SERVICE_ADDRESS = "firestore.googleapis.com".freeze
|
48
|
+
|
49
|
+
# The default port of the service.
|
50
|
+
DEFAULT_SERVICE_PORT = 443
|
51
|
+
|
52
|
+
# The default set of gRPC interceptors.
|
53
|
+
GRPC_INTERCEPTORS = []
|
54
|
+
|
55
|
+
DEFAULT_TIMEOUT = 30
|
56
|
+
|
57
|
+
PAGE_DESCRIPTORS = {
|
58
|
+
"list_indexes" => Google::Gax::PageDescriptor.new(
|
59
|
+
"page_token",
|
60
|
+
"next_page_token",
|
61
|
+
"indexes"),
|
62
|
+
"list_fields" => Google::Gax::PageDescriptor.new(
|
63
|
+
"page_token",
|
64
|
+
"next_page_token",
|
65
|
+
"fields")
|
66
|
+
}.freeze
|
67
|
+
|
68
|
+
private_constant :PAGE_DESCRIPTORS
|
69
|
+
|
70
|
+
# The scopes needed to make gRPC calls to all of the methods defined in
|
71
|
+
# this service.
|
72
|
+
ALL_SCOPES = [
|
73
|
+
"https://www.googleapis.com/auth/cloud-platform",
|
74
|
+
"https://www.googleapis.com/auth/datastore"
|
75
|
+
].freeze
|
76
|
+
|
77
|
+
|
78
|
+
DATABASE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
79
|
+
"projects/{project}/databases/{database}"
|
80
|
+
)
|
81
|
+
|
82
|
+
private_constant :DATABASE_PATH_TEMPLATE
|
83
|
+
|
84
|
+
FIELD_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
85
|
+
"projects/{project}/databases/{database}/collectionGroups/{collection_id}/fields/{field_id}"
|
86
|
+
)
|
87
|
+
|
88
|
+
private_constant :FIELD_PATH_TEMPLATE
|
89
|
+
|
90
|
+
INDEX_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
91
|
+
"projects/{project}/databases/{database}/collectionGroups/{collection_id}/indexes/{index_id}"
|
92
|
+
)
|
93
|
+
|
94
|
+
private_constant :INDEX_PATH_TEMPLATE
|
95
|
+
|
96
|
+
PARENT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
97
|
+
"projects/{project}/databases/{database}/collectionGroups/{collection_id}"
|
98
|
+
)
|
99
|
+
|
100
|
+
private_constant :PARENT_PATH_TEMPLATE
|
101
|
+
|
102
|
+
# Returns a fully-qualified database resource name string.
|
103
|
+
# @param project [String]
|
104
|
+
# @param database [String]
|
105
|
+
# @return [String]
|
106
|
+
def self.database_path project, database
|
107
|
+
DATABASE_PATH_TEMPLATE.render(
|
108
|
+
:"project" => project,
|
109
|
+
:"database" => database
|
110
|
+
)
|
111
|
+
end
|
112
|
+
|
113
|
+
# Returns a fully-qualified field resource name string.
|
114
|
+
# @param project [String]
|
115
|
+
# @param database [String]
|
116
|
+
# @param collection_id [String]
|
117
|
+
# @param field_id [String]
|
118
|
+
# @return [String]
|
119
|
+
def self.field_path project, database, collection_id, field_id
|
120
|
+
FIELD_PATH_TEMPLATE.render(
|
121
|
+
:"project" => project,
|
122
|
+
:"database" => database,
|
123
|
+
:"collection_id" => collection_id,
|
124
|
+
:"field_id" => field_id
|
125
|
+
)
|
126
|
+
end
|
127
|
+
|
128
|
+
# Returns a fully-qualified index resource name string.
|
129
|
+
# @param project [String]
|
130
|
+
# @param database [String]
|
131
|
+
# @param collection_id [String]
|
132
|
+
# @param index_id [String]
|
133
|
+
# @return [String]
|
134
|
+
def self.index_path project, database, collection_id, index_id
|
135
|
+
INDEX_PATH_TEMPLATE.render(
|
136
|
+
:"project" => project,
|
137
|
+
:"database" => database,
|
138
|
+
:"collection_id" => collection_id,
|
139
|
+
:"index_id" => index_id
|
140
|
+
)
|
141
|
+
end
|
142
|
+
|
143
|
+
# Returns a fully-qualified parent resource name string.
|
144
|
+
# @param project [String]
|
145
|
+
# @param database [String]
|
146
|
+
# @param collection_id [String]
|
147
|
+
# @return [String]
|
148
|
+
def self.parent_path project, database, collection_id
|
149
|
+
PARENT_PATH_TEMPLATE.render(
|
150
|
+
:"project" => project,
|
151
|
+
:"database" => database,
|
152
|
+
:"collection_id" => collection_id
|
153
|
+
)
|
154
|
+
end
|
155
|
+
|
156
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
157
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
158
|
+
# be many types.
|
159
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
160
|
+
# authenticating requests made by this client.
|
161
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
162
|
+
# credentials for this client.
|
163
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
164
|
+
# credentials for this client.
|
165
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
166
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
167
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
168
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
169
|
+
# metadata for requests, generally, to give OAuth credentials.
|
170
|
+
# @param scopes [Array<String>]
|
171
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
172
|
+
# an updater_proc is supplied.
|
173
|
+
# @param client_config [Hash]
|
174
|
+
# A Hash for call options for each method. See
|
175
|
+
# Google::Gax#construct_settings for the structure of
|
176
|
+
# this data. Falls back to the default config if not specified
|
177
|
+
# or the specified config is missing data points.
|
178
|
+
# @param timeout [Numeric]
|
179
|
+
# The default timeout, in seconds, for calls made through this client.
|
180
|
+
# @param metadata [Hash]
|
181
|
+
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
182
|
+
# @param service_address [String]
|
183
|
+
# Override for the service hostname, or `nil` to leave as the default.
|
184
|
+
# @param service_port [Integer]
|
185
|
+
# Override for the service port, or `nil` to leave as the default.
|
186
|
+
# @param exception_transformer [Proc]
|
187
|
+
# An optional proc that intercepts any exceptions raised during an API call to inject
|
188
|
+
# custom error handling.
|
189
|
+
def initialize \
|
190
|
+
credentials: nil,
|
191
|
+
scopes: ALL_SCOPES,
|
192
|
+
client_config: {},
|
193
|
+
timeout: DEFAULT_TIMEOUT,
|
194
|
+
metadata: nil,
|
195
|
+
service_address: nil,
|
196
|
+
service_port: nil,
|
197
|
+
exception_transformer: nil,
|
198
|
+
lib_name: nil,
|
199
|
+
lib_version: ""
|
200
|
+
# These require statements are intentionally placed here to initialize
|
201
|
+
# the gRPC module only when it's required.
|
202
|
+
# See https://github.com/googleapis/toolkit/issues/446
|
203
|
+
require "google/gax/grpc"
|
204
|
+
require "google/firestore/admin/v1/firestore_admin_services_pb"
|
205
|
+
|
206
|
+
credentials ||= Google::Cloud::Firestore::Admin::V1::Credentials.default
|
207
|
+
|
208
|
+
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
209
|
+
updater_proc = Google::Cloud::Firestore::Admin::V1::Credentials.new(credentials).updater_proc
|
210
|
+
end
|
211
|
+
if credentials.is_a?(GRPC::Core::Channel)
|
212
|
+
channel = credentials
|
213
|
+
end
|
214
|
+
if credentials.is_a?(GRPC::Core::ChannelCredentials)
|
215
|
+
chan_creds = credentials
|
216
|
+
end
|
217
|
+
if credentials.is_a?(Proc)
|
218
|
+
updater_proc = credentials
|
219
|
+
end
|
220
|
+
if credentials.is_a?(Google::Auth::Credentials)
|
221
|
+
updater_proc = credentials.updater_proc
|
222
|
+
end
|
223
|
+
|
224
|
+
package_version = Google::Cloud::Firestore::VERSION
|
225
|
+
|
226
|
+
google_api_client = "gl-ruby/#{RUBY_VERSION}"
|
227
|
+
google_api_client << " #{lib_name}/#{lib_version}" if lib_name
|
228
|
+
google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
|
229
|
+
google_api_client << " grpc/#{GRPC::VERSION}"
|
230
|
+
google_api_client.freeze
|
231
|
+
|
232
|
+
headers = { :"x-goog-api-client" => google_api_client }
|
233
|
+
headers.merge!(metadata) unless metadata.nil?
|
234
|
+
client_config_file = Pathname.new(__dir__).join(
|
235
|
+
"firestore_admin_client_config.json"
|
236
|
+
)
|
237
|
+
defaults = client_config_file.open do |f|
|
238
|
+
Google::Gax.construct_settings(
|
239
|
+
"google.firestore.admin.v1.FirestoreAdmin",
|
240
|
+
JSON.parse(f.read),
|
241
|
+
client_config,
|
242
|
+
Google::Gax::Grpc::STATUS_CODE_NAMES,
|
243
|
+
timeout,
|
244
|
+
page_descriptors: PAGE_DESCRIPTORS,
|
245
|
+
errors: Google::Gax::Grpc::API_ERRORS,
|
246
|
+
metadata: headers
|
247
|
+
)
|
248
|
+
end
|
249
|
+
|
250
|
+
# Allow overriding the service path/port in subclasses.
|
251
|
+
service_path = service_address || self.class::SERVICE_ADDRESS
|
252
|
+
port = service_port || self.class::DEFAULT_SERVICE_PORT
|
253
|
+
interceptors = self.class::GRPC_INTERCEPTORS
|
254
|
+
@firestore_admin_stub = Google::Gax::Grpc.create_stub(
|
255
|
+
service_path,
|
256
|
+
port,
|
257
|
+
chan_creds: chan_creds,
|
258
|
+
channel: channel,
|
259
|
+
updater_proc: updater_proc,
|
260
|
+
scopes: scopes,
|
261
|
+
interceptors: interceptors,
|
262
|
+
&Google::Firestore::Admin::V1::FirestoreAdmin::Stub.method(:new)
|
263
|
+
)
|
264
|
+
|
265
|
+
@create_index = Google::Gax.create_api_call(
|
266
|
+
@firestore_admin_stub.method(:create_index),
|
267
|
+
defaults["create_index"],
|
268
|
+
exception_transformer: exception_transformer,
|
269
|
+
params_extractor: proc do |request|
|
270
|
+
{'parent' => request.parent}
|
271
|
+
end
|
272
|
+
)
|
273
|
+
@list_indexes = Google::Gax.create_api_call(
|
274
|
+
@firestore_admin_stub.method(:list_indexes),
|
275
|
+
defaults["list_indexes"],
|
276
|
+
exception_transformer: exception_transformer,
|
277
|
+
params_extractor: proc do |request|
|
278
|
+
{'parent' => request.parent}
|
279
|
+
end
|
280
|
+
)
|
281
|
+
@get_index = Google::Gax.create_api_call(
|
282
|
+
@firestore_admin_stub.method(:get_index),
|
283
|
+
defaults["get_index"],
|
284
|
+
exception_transformer: exception_transformer,
|
285
|
+
params_extractor: proc do |request|
|
286
|
+
{'name' => request.name}
|
287
|
+
end
|
288
|
+
)
|
289
|
+
@delete_index = Google::Gax.create_api_call(
|
290
|
+
@firestore_admin_stub.method(:delete_index),
|
291
|
+
defaults["delete_index"],
|
292
|
+
exception_transformer: exception_transformer,
|
293
|
+
params_extractor: proc do |request|
|
294
|
+
{'name' => request.name}
|
295
|
+
end
|
296
|
+
)
|
297
|
+
@import_documents = Google::Gax.create_api_call(
|
298
|
+
@firestore_admin_stub.method(:import_documents),
|
299
|
+
defaults["import_documents"],
|
300
|
+
exception_transformer: exception_transformer,
|
301
|
+
params_extractor: proc do |request|
|
302
|
+
{'name' => request.name}
|
303
|
+
end
|
304
|
+
)
|
305
|
+
@export_documents = Google::Gax.create_api_call(
|
306
|
+
@firestore_admin_stub.method(:export_documents),
|
307
|
+
defaults["export_documents"],
|
308
|
+
exception_transformer: exception_transformer,
|
309
|
+
params_extractor: proc do |request|
|
310
|
+
{'name' => request.name}
|
311
|
+
end
|
312
|
+
)
|
313
|
+
@get_field = Google::Gax.create_api_call(
|
314
|
+
@firestore_admin_stub.method(:get_field),
|
315
|
+
defaults["get_field"],
|
316
|
+
exception_transformer: exception_transformer,
|
317
|
+
params_extractor: proc do |request|
|
318
|
+
{'name' => request.name}
|
319
|
+
end
|
320
|
+
)
|
321
|
+
@list_fields = Google::Gax.create_api_call(
|
322
|
+
@firestore_admin_stub.method(:list_fields),
|
323
|
+
defaults["list_fields"],
|
324
|
+
exception_transformer: exception_transformer,
|
325
|
+
params_extractor: proc do |request|
|
326
|
+
{'parent' => request.parent}
|
327
|
+
end
|
328
|
+
)
|
329
|
+
@update_field = Google::Gax.create_api_call(
|
330
|
+
@firestore_admin_stub.method(:update_field),
|
331
|
+
defaults["update_field"],
|
332
|
+
exception_transformer: exception_transformer,
|
333
|
+
params_extractor: proc do |request|
|
334
|
+
{'field.name' => request.field.name}
|
335
|
+
end
|
336
|
+
)
|
337
|
+
end
|
338
|
+
|
339
|
+
# Service calls
|
340
|
+
|
341
|
+
# Creates a composite index. This returns a {Google::Longrunning::Operation}
|
342
|
+
# which may be used to track the status of the creation. The metadata for
|
343
|
+
# the operation will be the type {Google::Firestore::Admin::V1::IndexOperationMetadata IndexOperationMetadata}.
|
344
|
+
#
|
345
|
+
# @param parent [String]
|
346
|
+
# A parent name of the form
|
347
|
+
# `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
|
348
|
+
# @param index [Google::Firestore::Admin::V1::Index | Hash]
|
349
|
+
# The composite index to create.
|
350
|
+
# A hash of the same form as `Google::Firestore::Admin::V1::Index`
|
351
|
+
# can also be provided.
|
352
|
+
# @param options [Google::Gax::CallOptions]
|
353
|
+
# Overrides the default settings for this call, e.g, timeout,
|
354
|
+
# retries, etc.
|
355
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
356
|
+
# @yieldparam result [Google::Longrunning::Operation]
|
357
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
358
|
+
# @return [Google::Longrunning::Operation]
|
359
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
360
|
+
# @example
|
361
|
+
# require "google/cloud/firestore/admin"
|
362
|
+
#
|
363
|
+
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
364
|
+
# formatted_parent = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.parent_path("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]")
|
365
|
+
#
|
366
|
+
# # TODO: Initialize `index`:
|
367
|
+
# index = {}
|
368
|
+
# response = firestore_admin_client.create_index(formatted_parent, index)
|
369
|
+
|
370
|
+
def create_index \
|
371
|
+
parent,
|
372
|
+
index,
|
373
|
+
options: nil,
|
374
|
+
&block
|
375
|
+
req = {
|
376
|
+
parent: parent,
|
377
|
+
index: index
|
378
|
+
}.delete_if { |_, v| v.nil? }
|
379
|
+
req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::CreateIndexRequest)
|
380
|
+
@create_index.call(req, options, &block)
|
381
|
+
end
|
382
|
+
|
383
|
+
# Lists composite indexes.
|
384
|
+
#
|
385
|
+
# @param parent [String]
|
386
|
+
# A parent name of the form
|
387
|
+
# `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
|
388
|
+
# @param filter [String]
|
389
|
+
# The filter to apply to list results.
|
390
|
+
# @param page_size [Integer]
|
391
|
+
# The maximum number of resources contained in the underlying API
|
392
|
+
# response. If page streaming is performed per-resource, this
|
393
|
+
# parameter does not affect the return value. If page streaming is
|
394
|
+
# performed per-page, this determines the maximum number of
|
395
|
+
# resources in a page.
|
396
|
+
# @param options [Google::Gax::CallOptions]
|
397
|
+
# Overrides the default settings for this call, e.g, timeout,
|
398
|
+
# retries, etc.
|
399
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
400
|
+
# @yieldparam result [Google::Gax::PagedEnumerable<Google::Firestore::Admin::V1::Index>]
|
401
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
402
|
+
# @return [Google::Gax::PagedEnumerable<Google::Firestore::Admin::V1::Index>]
|
403
|
+
# An enumerable of Google::Firestore::Admin::V1::Index instances.
|
404
|
+
# See Google::Gax::PagedEnumerable documentation for other
|
405
|
+
# operations such as per-page iteration or access to the response
|
406
|
+
# object.
|
407
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
408
|
+
# @example
|
409
|
+
# require "google/cloud/firestore/admin"
|
410
|
+
#
|
411
|
+
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
412
|
+
# formatted_parent = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.parent_path("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]")
|
413
|
+
#
|
414
|
+
# # Iterate over all results.
|
415
|
+
# firestore_admin_client.list_indexes(formatted_parent).each do |element|
|
416
|
+
# # Process element.
|
417
|
+
# end
|
418
|
+
#
|
419
|
+
# # Or iterate over results one page at a time.
|
420
|
+
# firestore_admin_client.list_indexes(formatted_parent).each_page do |page|
|
421
|
+
# # Process each page at a time.
|
422
|
+
# page.each do |element|
|
423
|
+
# # Process element.
|
424
|
+
# end
|
425
|
+
# end
|
426
|
+
|
427
|
+
def list_indexes \
|
428
|
+
parent,
|
429
|
+
filter: nil,
|
430
|
+
page_size: nil,
|
431
|
+
options: nil,
|
432
|
+
&block
|
433
|
+
req = {
|
434
|
+
parent: parent,
|
435
|
+
filter: filter,
|
436
|
+
page_size: page_size
|
437
|
+
}.delete_if { |_, v| v.nil? }
|
438
|
+
req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::ListIndexesRequest)
|
439
|
+
@list_indexes.call(req, options, &block)
|
440
|
+
end
|
441
|
+
|
442
|
+
# Gets a composite index.
|
443
|
+
#
|
444
|
+
# @param name [String]
|
445
|
+
# A name of the form
|
446
|
+
# `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
|
447
|
+
# @param options [Google::Gax::CallOptions]
|
448
|
+
# Overrides the default settings for this call, e.g, timeout,
|
449
|
+
# retries, etc.
|
450
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
451
|
+
# @yieldparam result [Google::Firestore::Admin::V1::Index]
|
452
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
453
|
+
# @return [Google::Firestore::Admin::V1::Index]
|
454
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
455
|
+
# @example
|
456
|
+
# require "google/cloud/firestore/admin"
|
457
|
+
#
|
458
|
+
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
459
|
+
# formatted_name = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.index_path("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[INDEX_ID]")
|
460
|
+
# response = firestore_admin_client.get_index(formatted_name)
|
461
|
+
|
462
|
+
def get_index \
|
463
|
+
name,
|
464
|
+
options: nil,
|
465
|
+
&block
|
466
|
+
req = {
|
467
|
+
name: name
|
468
|
+
}.delete_if { |_, v| v.nil? }
|
469
|
+
req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::GetIndexRequest)
|
470
|
+
@get_index.call(req, options, &block)
|
471
|
+
end
|
472
|
+
|
473
|
+
# Deletes a composite index.
|
474
|
+
#
|
475
|
+
# @param name [String]
|
476
|
+
# A name of the form
|
477
|
+
# `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
|
478
|
+
# @param options [Google::Gax::CallOptions]
|
479
|
+
# Overrides the default settings for this call, e.g, timeout,
|
480
|
+
# retries, etc.
|
481
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
482
|
+
# @yieldparam result []
|
483
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
484
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
485
|
+
# @example
|
486
|
+
# require "google/cloud/firestore/admin"
|
487
|
+
#
|
488
|
+
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
489
|
+
# formatted_name = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.index_path("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[INDEX_ID]")
|
490
|
+
# firestore_admin_client.delete_index(formatted_name)
|
491
|
+
|
492
|
+
def delete_index \
|
493
|
+
name,
|
494
|
+
options: nil,
|
495
|
+
&block
|
496
|
+
req = {
|
497
|
+
name: name
|
498
|
+
}.delete_if { |_, v| v.nil? }
|
499
|
+
req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::DeleteIndexRequest)
|
500
|
+
@delete_index.call(req, options, &block)
|
501
|
+
nil
|
502
|
+
end
|
503
|
+
|
504
|
+
# Imports documents into Google Cloud Firestore. Existing documents with the
|
505
|
+
# same name are overwritten. The import occurs in the background and its
|
506
|
+
# progress can be monitored and managed via the Operation resource that is
|
507
|
+
# created. If an ImportDocuments operation is cancelled, it is possible
|
508
|
+
# that a subset of the data has already been imported to Cloud Firestore.
|
509
|
+
#
|
510
|
+
# @param name [String]
|
511
|
+
# Database to import into. Should be of the form:
|
512
|
+
# `projects/{project_id}/databases/{database_id}`.
|
513
|
+
# @param collection_ids [Array<String>]
|
514
|
+
# Which collection ids to import. Unspecified means all collections included
|
515
|
+
# in the import.
|
516
|
+
# @param input_uri_prefix [String]
|
517
|
+
# Location of the exported files.
|
518
|
+
# This must match the output_uri_prefix of an ExportDocumentsResponse from
|
519
|
+
# an export that has completed successfully.
|
520
|
+
# See:
|
521
|
+
# {Google::Firestore::Admin::V1::ExportDocumentsResponse#output_uri_prefix}.
|
522
|
+
# @param options [Google::Gax::CallOptions]
|
523
|
+
# Overrides the default settings for this call, e.g, timeout,
|
524
|
+
# retries, etc.
|
525
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
526
|
+
# @yieldparam result [Google::Longrunning::Operation]
|
527
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
528
|
+
# @return [Google::Longrunning::Operation]
|
529
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
530
|
+
# @example
|
531
|
+
# require "google/cloud/firestore/admin"
|
532
|
+
#
|
533
|
+
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
534
|
+
# formatted_name = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.database_path("[PROJECT]", "[DATABASE]")
|
535
|
+
# response = firestore_admin_client.import_documents(formatted_name)
|
536
|
+
|
537
|
+
def import_documents \
|
538
|
+
name,
|
539
|
+
collection_ids: nil,
|
540
|
+
input_uri_prefix: nil,
|
541
|
+
options: nil,
|
542
|
+
&block
|
543
|
+
req = {
|
544
|
+
name: name,
|
545
|
+
collection_ids: collection_ids,
|
546
|
+
input_uri_prefix: input_uri_prefix
|
547
|
+
}.delete_if { |_, v| v.nil? }
|
548
|
+
req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::ImportDocumentsRequest)
|
549
|
+
@import_documents.call(req, options, &block)
|
550
|
+
end
|
551
|
+
|
552
|
+
# Exports a copy of all or a subset of documents from Google Cloud Firestore
|
553
|
+
# to another storage system, such as Google Cloud Storage. Recent updates to
|
554
|
+
# documents may not be reflected in the export. The export occurs in the
|
555
|
+
# background and its progress can be monitored and managed via the
|
556
|
+
# Operation resource that is created. The output of an export may only be
|
557
|
+
# used once the associated operation is done. If an export operation is
|
558
|
+
# cancelled before completion it may leave partial data behind in Google
|
559
|
+
# Cloud Storage.
|
560
|
+
#
|
561
|
+
# @param name [String]
|
562
|
+
# Database to export. Should be of the form:
|
563
|
+
# `projects/{project_id}/databases/{database_id}`.
|
564
|
+
# @param collection_ids [Array<String>]
|
565
|
+
# Which collection ids to export. Unspecified means all collections.
|
566
|
+
# @param output_uri_prefix [String]
|
567
|
+
# The output URI. Currently only supports Google Cloud Storage URIs of the
|
568
|
+
# form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name
|
569
|
+
# of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional
|
570
|
+
# Google Cloud Storage namespace path. When
|
571
|
+
# choosing a name, be sure to consider Google Cloud Storage naming
|
572
|
+
# guidelines: https://cloud.google.com/storage/docs/naming.
|
573
|
+
# If the URI is a bucket (without a namespace path), a prefix will be
|
574
|
+
# generated based on the start time.
|
575
|
+
# @param options [Google::Gax::CallOptions]
|
576
|
+
# Overrides the default settings for this call, e.g, timeout,
|
577
|
+
# retries, etc.
|
578
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
579
|
+
# @yieldparam result [Google::Longrunning::Operation]
|
580
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
581
|
+
# @return [Google::Longrunning::Operation]
|
582
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
583
|
+
# @example
|
584
|
+
# require "google/cloud/firestore/admin"
|
585
|
+
#
|
586
|
+
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
587
|
+
# formatted_name = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.database_path("[PROJECT]", "[DATABASE]")
|
588
|
+
# response = firestore_admin_client.export_documents(formatted_name)
|
589
|
+
|
590
|
+
def export_documents \
|
591
|
+
name,
|
592
|
+
collection_ids: nil,
|
593
|
+
output_uri_prefix: nil,
|
594
|
+
options: nil,
|
595
|
+
&block
|
596
|
+
req = {
|
597
|
+
name: name,
|
598
|
+
collection_ids: collection_ids,
|
599
|
+
output_uri_prefix: output_uri_prefix
|
600
|
+
}.delete_if { |_, v| v.nil? }
|
601
|
+
req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::ExportDocumentsRequest)
|
602
|
+
@export_documents.call(req, options, &block)
|
603
|
+
end
|
604
|
+
|
605
|
+
# Gets the metadata and configuration for a Field.
|
606
|
+
#
|
607
|
+
# @param name [String]
|
608
|
+
# A name of the form
|
609
|
+
# `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}`
|
610
|
+
# @param options [Google::Gax::CallOptions]
|
611
|
+
# Overrides the default settings for this call, e.g, timeout,
|
612
|
+
# retries, etc.
|
613
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
614
|
+
# @yieldparam result [Google::Firestore::Admin::V1::Field]
|
615
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
616
|
+
# @return [Google::Firestore::Admin::V1::Field]
|
617
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
618
|
+
# @example
|
619
|
+
# require "google/cloud/firestore/admin"
|
620
|
+
#
|
621
|
+
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
622
|
+
# formatted_name = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.field_path("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[FIELD_ID]")
|
623
|
+
# response = firestore_admin_client.get_field(formatted_name)
|
624
|
+
|
625
|
+
def get_field \
|
626
|
+
name,
|
627
|
+
options: nil,
|
628
|
+
&block
|
629
|
+
req = {
|
630
|
+
name: name
|
631
|
+
}.delete_if { |_, v| v.nil? }
|
632
|
+
req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::GetFieldRequest)
|
633
|
+
@get_field.call(req, options, &block)
|
634
|
+
end
|
635
|
+
|
636
|
+
# Lists the field configuration and metadata for this database.
|
637
|
+
#
|
638
|
+
# Currently, {Google::Firestore::Admin::V1::FirestoreAdmin::ListFields FirestoreAdmin::ListFields} only supports listing fields
|
639
|
+
# that have been explicitly overridden. To issue this query, call
|
640
|
+
# {Google::Firestore::Admin::V1::FirestoreAdmin::ListFields FirestoreAdmin::ListFields} with the filter set to
|
641
|
+
# `indexConfig.usesAncestorConfig:false`.
|
642
|
+
#
|
643
|
+
# @param parent [String]
|
644
|
+
# A parent name of the form
|
645
|
+
# `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
|
646
|
+
# @param filter [String]
|
647
|
+
# The filter to apply to list results. Currently,
|
648
|
+
# {Google::Firestore::Admin::V1::FirestoreAdmin::ListFields FirestoreAdmin::ListFields} only supports listing fields
|
649
|
+
# that have been explicitly overridden. To issue this query, call
|
650
|
+
# {Google::Firestore::Admin::V1::FirestoreAdmin::ListFields FirestoreAdmin::ListFields} with the filter set to
|
651
|
+
# `indexConfig.usesAncestorConfig:false`.
|
652
|
+
# @param page_size [Integer]
|
653
|
+
# The maximum number of resources contained in the underlying API
|
654
|
+
# response. If page streaming is performed per-resource, this
|
655
|
+
# parameter does not affect the return value. If page streaming is
|
656
|
+
# performed per-page, this determines the maximum number of
|
657
|
+
# resources in a page.
|
658
|
+
# @param options [Google::Gax::CallOptions]
|
659
|
+
# Overrides the default settings for this call, e.g, timeout,
|
660
|
+
# retries, etc.
|
661
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
662
|
+
# @yieldparam result [Google::Gax::PagedEnumerable<Google::Firestore::Admin::V1::Field>]
|
663
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
664
|
+
# @return [Google::Gax::PagedEnumerable<Google::Firestore::Admin::V1::Field>]
|
665
|
+
# An enumerable of Google::Firestore::Admin::V1::Field instances.
|
666
|
+
# See Google::Gax::PagedEnumerable documentation for other
|
667
|
+
# operations such as per-page iteration or access to the response
|
668
|
+
# object.
|
669
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
670
|
+
# @example
|
671
|
+
# require "google/cloud/firestore/admin"
|
672
|
+
#
|
673
|
+
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
674
|
+
# formatted_parent = Google::Cloud::Firestore::Admin::V1::FirestoreAdminClient.parent_path("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]")
|
675
|
+
#
|
676
|
+
# # Iterate over all results.
|
677
|
+
# firestore_admin_client.list_fields(formatted_parent).each do |element|
|
678
|
+
# # Process element.
|
679
|
+
# end
|
680
|
+
#
|
681
|
+
# # Or iterate over results one page at a time.
|
682
|
+
# firestore_admin_client.list_fields(formatted_parent).each_page do |page|
|
683
|
+
# # Process each page at a time.
|
684
|
+
# page.each do |element|
|
685
|
+
# # Process element.
|
686
|
+
# end
|
687
|
+
# end
|
688
|
+
|
689
|
+
def list_fields \
|
690
|
+
parent,
|
691
|
+
filter: nil,
|
692
|
+
page_size: nil,
|
693
|
+
options: nil,
|
694
|
+
&block
|
695
|
+
req = {
|
696
|
+
parent: parent,
|
697
|
+
filter: filter,
|
698
|
+
page_size: page_size
|
699
|
+
}.delete_if { |_, v| v.nil? }
|
700
|
+
req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::ListFieldsRequest)
|
701
|
+
@list_fields.call(req, options, &block)
|
702
|
+
end
|
703
|
+
|
704
|
+
# Updates a field configuration. Currently, field updates apply only to
|
705
|
+
# single field index configuration. However, calls to
|
706
|
+
# {Google::Firestore::Admin::V1::FirestoreAdmin::UpdateField FirestoreAdmin::UpdateField} should provide a field mask to avoid
|
707
|
+
# changing any configuration that the caller isn't aware of. The field mask
|
708
|
+
# should be specified as: `{ paths: "index_config" }`.
|
709
|
+
#
|
710
|
+
# This call returns a {Google::Longrunning::Operation} which may be used to
|
711
|
+
# track the status of the field update. The metadata for
|
712
|
+
# the operation will be the type {Google::Firestore::Admin::V1::FieldOperationMetadata FieldOperationMetadata}.
|
713
|
+
#
|
714
|
+
# To configure the default field settings for the database, use
|
715
|
+
# the special `Field` with resource name:
|
716
|
+
# `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`.
|
717
|
+
#
|
718
|
+
# @param field [Google::Firestore::Admin::V1::Field | Hash]
|
719
|
+
# The field to be updated.
|
720
|
+
# A hash of the same form as `Google::Firestore::Admin::V1::Field`
|
721
|
+
# can also be provided.
|
722
|
+
# @param update_mask [Google::Protobuf::FieldMask | Hash]
|
723
|
+
# A mask, relative to the field. If specified, only configuration specified
|
724
|
+
# by this field_mask will be updated in the field.
|
725
|
+
# A hash of the same form as `Google::Protobuf::FieldMask`
|
726
|
+
# can also be provided.
|
727
|
+
# @param options [Google::Gax::CallOptions]
|
728
|
+
# Overrides the default settings for this call, e.g, timeout,
|
729
|
+
# retries, etc.
|
730
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
731
|
+
# @yieldparam result [Google::Longrunning::Operation]
|
732
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
733
|
+
# @return [Google::Longrunning::Operation]
|
734
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
735
|
+
# @example
|
736
|
+
# require "google/cloud/firestore/admin"
|
737
|
+
#
|
738
|
+
# firestore_admin_client = Google::Cloud::Firestore::Admin.new(version: :v1)
|
739
|
+
#
|
740
|
+
# # TODO: Initialize `field`:
|
741
|
+
# field = {}
|
742
|
+
# response = firestore_admin_client.update_field(field)
|
743
|
+
|
744
|
+
def update_field \
|
745
|
+
field,
|
746
|
+
update_mask: nil,
|
747
|
+
options: nil,
|
748
|
+
&block
|
749
|
+
req = {
|
750
|
+
field: field,
|
751
|
+
update_mask: update_mask
|
752
|
+
}.delete_if { |_, v| v.nil? }
|
753
|
+
req = Google::Gax::to_proto(req, Google::Firestore::Admin::V1::UpdateFieldRequest)
|
754
|
+
@update_field.call(req, options, &block)
|
755
|
+
end
|
756
|
+
end
|
757
|
+
end
|
758
|
+
end
|
759
|
+
end
|
760
|
+
end
|
761
|
+
end
|