google-cloud-firestore 0.20.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 +7 -0
- data/.yardopts +8 -0
- data/LICENSE +201 -0
- data/README.md +30 -0
- data/lib/google-cloud-firestore.rb +106 -0
- data/lib/google/cloud/firestore.rb +514 -0
- data/lib/google/cloud/firestore/batch.rb +462 -0
- data/lib/google/cloud/firestore/client.rb +449 -0
- data/lib/google/cloud/firestore/collection_reference.rb +249 -0
- data/lib/google/cloud/firestore/commit_response.rb +145 -0
- data/lib/google/cloud/firestore/convert.rb +561 -0
- data/lib/google/cloud/firestore/credentials.rb +35 -0
- data/lib/google/cloud/firestore/document_reference.rb +468 -0
- data/lib/google/cloud/firestore/document_snapshot.rb +324 -0
- data/lib/google/cloud/firestore/field_path.rb +216 -0
- data/lib/google/cloud/firestore/field_value.rb +113 -0
- data/lib/google/cloud/firestore/generate.rb +35 -0
- data/lib/google/cloud/firestore/query.rb +651 -0
- data/lib/google/cloud/firestore/service.rb +176 -0
- data/lib/google/cloud/firestore/transaction.rb +726 -0
- data/lib/google/cloud/firestore/v1beta1.rb +121 -0
- data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/common.rb +63 -0
- data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/document.rb +134 -0
- data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/firestore.rb +584 -0
- data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/query.rb +215 -0
- data/lib/google/cloud/firestore/v1beta1/doc/google/firestore/v1beta1/write.rb +167 -0
- data/lib/google/cloud/firestore/v1beta1/doc/google/protobuf/any.rb +124 -0
- data/lib/google/cloud/firestore/v1beta1/doc/google/protobuf/timestamp.rb +106 -0
- data/lib/google/cloud/firestore/v1beta1/doc/google/protobuf/wrappers.rb +89 -0
- data/lib/google/cloud/firestore/v1beta1/doc/google/rpc/status.rb +83 -0
- data/lib/google/cloud/firestore/v1beta1/doc/overview.rb +53 -0
- data/lib/google/cloud/firestore/v1beta1/firestore_client.rb +974 -0
- data/lib/google/cloud/firestore/v1beta1/firestore_client_config.json +100 -0
- data/lib/google/cloud/firestore/version.rb +22 -0
- data/lib/google/firestore/v1beta1/common_pb.rb +44 -0
- data/lib/google/firestore/v1beta1/document_pb.rb +49 -0
- data/lib/google/firestore/v1beta1/firestore_pb.rb +219 -0
- data/lib/google/firestore/v1beta1/firestore_services_pb.rb +87 -0
- data/lib/google/firestore/v1beta1/query_pb.rb +103 -0
- data/lib/google/firestore/v1beta1/write_pb.rb +73 -0
- metadata +251 -0
@@ -0,0 +1,215 @@
|
|
1
|
+
# Copyright 2017 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
|
+
module Google
|
16
|
+
module Firestore
|
17
|
+
module V1beta1
|
18
|
+
# A Firestore query.
|
19
|
+
# @!attribute [rw] select
|
20
|
+
# @return [Google::Firestore::V1beta1::StructuredQuery::Projection]
|
21
|
+
# The projection to return.
|
22
|
+
# @!attribute [rw] from
|
23
|
+
# @return [Array<Google::Firestore::V1beta1::StructuredQuery::CollectionSelector>]
|
24
|
+
# The collections to query.
|
25
|
+
# @!attribute [rw] where
|
26
|
+
# @return [Google::Firestore::V1beta1::StructuredQuery::Filter]
|
27
|
+
# The filter to apply.
|
28
|
+
# @!attribute [rw] order_by
|
29
|
+
# @return [Array<Google::Firestore::V1beta1::StructuredQuery::Order>]
|
30
|
+
# The order to apply to the query results.
|
31
|
+
#
|
32
|
+
# Firestore guarantees a stable ordering through the following rules:
|
33
|
+
#
|
34
|
+
# * Any field required to appear in +order_by+, that is not already
|
35
|
+
# specified in +order_by+, is appended to the order in field name order
|
36
|
+
# by default.
|
37
|
+
# * If an order on +__name__+ is not specified, it is appended by default.
|
38
|
+
#
|
39
|
+
# Fields are appended with the same sort direction as the last order
|
40
|
+
# specified, or 'ASCENDING' if no order was specified. For example:
|
41
|
+
#
|
42
|
+
# * +SELECT * FROM Foo ORDER BY A+ becomes
|
43
|
+
# +SELECT * FROM Foo ORDER BY A, __name__+
|
44
|
+
# * +SELECT * FROM Foo ORDER BY A DESC+ becomes
|
45
|
+
# +SELECT * FROM Foo ORDER BY A DESC, __name__ DESC+
|
46
|
+
# * +SELECT * FROM Foo WHERE A > 1+ becomes
|
47
|
+
# +SELECT * FROM Foo WHERE A > 1 ORDER BY A, __name__+
|
48
|
+
# @!attribute [rw] start_at
|
49
|
+
# @return [Google::Firestore::V1beta1::Cursor]
|
50
|
+
# A starting point for the query results.
|
51
|
+
# @!attribute [rw] end_at
|
52
|
+
# @return [Google::Firestore::V1beta1::Cursor]
|
53
|
+
# A end point for the query results.
|
54
|
+
# @!attribute [rw] offset
|
55
|
+
# @return [Integer]
|
56
|
+
# The number of results to skip.
|
57
|
+
#
|
58
|
+
# Applies before limit, but after all other constraints. Must be >= 0 if
|
59
|
+
# specified.
|
60
|
+
# @!attribute [rw] limit
|
61
|
+
# @return [Google::Protobuf::Int32Value]
|
62
|
+
# The maximum number of results to return.
|
63
|
+
#
|
64
|
+
# Applies after all other constraints.
|
65
|
+
# Must be >= 0 if specified.
|
66
|
+
class StructuredQuery
|
67
|
+
# A selection of a collection, such as +messages as m1+.
|
68
|
+
# @!attribute [rw] collection_id
|
69
|
+
# @return [String]
|
70
|
+
# The collection ID.
|
71
|
+
# When set, selects only collections with this ID.
|
72
|
+
# @!attribute [rw] all_descendants
|
73
|
+
# @return [true, false]
|
74
|
+
# When false, selects only collections that are immediate children of
|
75
|
+
# the +parent+ specified in the containing +RunQueryRequest+.
|
76
|
+
# When true, selects all descendant collections.
|
77
|
+
class CollectionSelector; end
|
78
|
+
|
79
|
+
# A filter.
|
80
|
+
# @!attribute [rw] composite_filter
|
81
|
+
# @return [Google::Firestore::V1beta1::StructuredQuery::CompositeFilter]
|
82
|
+
# A composite filter.
|
83
|
+
# @!attribute [rw] field_filter
|
84
|
+
# @return [Google::Firestore::V1beta1::StructuredQuery::FieldFilter]
|
85
|
+
# A filter on a document field.
|
86
|
+
# @!attribute [rw] unary_filter
|
87
|
+
# @return [Google::Firestore::V1beta1::StructuredQuery::UnaryFilter]
|
88
|
+
# A filter that takes exactly one argument.
|
89
|
+
class Filter; end
|
90
|
+
|
91
|
+
# A filter that merges multiple other filters using the given operator.
|
92
|
+
# @!attribute [rw] op
|
93
|
+
# @return [Google::Firestore::V1beta1::StructuredQuery::CompositeFilter::Operator]
|
94
|
+
# The operator for combining multiple filters.
|
95
|
+
# @!attribute [rw] filters
|
96
|
+
# @return [Array<Google::Firestore::V1beta1::StructuredQuery::Filter>]
|
97
|
+
# The list of filters to combine.
|
98
|
+
# Must contain at least one filter.
|
99
|
+
class CompositeFilter
|
100
|
+
# A composite filter operator.
|
101
|
+
module Operator
|
102
|
+
# Unspecified. This value must not be used.
|
103
|
+
OPERATOR_UNSPECIFIED = 0
|
104
|
+
|
105
|
+
# The results are required to satisfy each of the combined filters.
|
106
|
+
AND = 1
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# A filter on a specific field.
|
111
|
+
# @!attribute [rw] field
|
112
|
+
# @return [Google::Firestore::V1beta1::StructuredQuery::FieldReference]
|
113
|
+
# The field to filter by.
|
114
|
+
# @!attribute [rw] op
|
115
|
+
# @return [Google::Firestore::V1beta1::StructuredQuery::FieldFilter::Operator]
|
116
|
+
# The operator to filter by.
|
117
|
+
# @!attribute [rw] value
|
118
|
+
# @return [Google::Firestore::V1beta1::Value]
|
119
|
+
# The value to compare to.
|
120
|
+
class FieldFilter
|
121
|
+
# A field filter operator.
|
122
|
+
module Operator
|
123
|
+
# Unspecified. This value must not be used.
|
124
|
+
OPERATOR_UNSPECIFIED = 0
|
125
|
+
|
126
|
+
# Less than. Requires that the field come first in +order_by+.
|
127
|
+
LESS_THAN = 1
|
128
|
+
|
129
|
+
# Less than or equal. Requires that the field come first in +order_by+.
|
130
|
+
LESS_THAN_OR_EQUAL = 2
|
131
|
+
|
132
|
+
# Greater than. Requires that the field come first in +order_by+.
|
133
|
+
GREATER_THAN = 3
|
134
|
+
|
135
|
+
# Greater than or equal. Requires that the field come first in
|
136
|
+
# +order_by+.
|
137
|
+
GREATER_THAN_OR_EQUAL = 4
|
138
|
+
|
139
|
+
# Equal.
|
140
|
+
EQUAL = 5
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
# A filter with a single operand.
|
145
|
+
# @!attribute [rw] op
|
146
|
+
# @return [Google::Firestore::V1beta1::StructuredQuery::UnaryFilter::Operator]
|
147
|
+
# The unary operator to apply.
|
148
|
+
# @!attribute [rw] field
|
149
|
+
# @return [Google::Firestore::V1beta1::StructuredQuery::FieldReference]
|
150
|
+
# The field to which to apply the operator.
|
151
|
+
class UnaryFilter
|
152
|
+
# A unary operator.
|
153
|
+
module Operator
|
154
|
+
# Unspecified. This value must not be used.
|
155
|
+
OPERATOR_UNSPECIFIED = 0
|
156
|
+
|
157
|
+
# Test if a field is equal to NaN.
|
158
|
+
IS_NAN = 2
|
159
|
+
|
160
|
+
# Test if an exprestion evaluates to Null.
|
161
|
+
IS_NULL = 3
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
# An order on a field.
|
166
|
+
# @!attribute [rw] field
|
167
|
+
# @return [Google::Firestore::V1beta1::StructuredQuery::FieldReference]
|
168
|
+
# The field to order by.
|
169
|
+
# @!attribute [rw] direction
|
170
|
+
# @return [Google::Firestore::V1beta1::StructuredQuery::Direction]
|
171
|
+
# The direction to order by. Defaults to +ASCENDING+.
|
172
|
+
class Order; end
|
173
|
+
|
174
|
+
# A reference to a field, such as +max(messages.time) as max_time+.
|
175
|
+
# @!attribute [rw] field_path
|
176
|
+
# @return [String]
|
177
|
+
class FieldReference; end
|
178
|
+
|
179
|
+
# The projection of document's fields to return.
|
180
|
+
# @!attribute [rw] fields
|
181
|
+
# @return [Array<Google::Firestore::V1beta1::StructuredQuery::FieldReference>]
|
182
|
+
# The fields to return.
|
183
|
+
#
|
184
|
+
# If empty, all fields are returned. To only return the name
|
185
|
+
# of the document, use +['__name__']+.
|
186
|
+
class Projection; end
|
187
|
+
|
188
|
+
# A sort direction.
|
189
|
+
module Direction
|
190
|
+
# Unspecified.
|
191
|
+
DIRECTION_UNSPECIFIED = 0
|
192
|
+
|
193
|
+
# Ascending.
|
194
|
+
ASCENDING = 1
|
195
|
+
|
196
|
+
# Descending.
|
197
|
+
DESCENDING = 2
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
# A position in a query result set.
|
202
|
+
# @!attribute [rw] values
|
203
|
+
# @return [Array<Google::Firestore::V1beta1::Value>]
|
204
|
+
# The values that represent a position, in the order they appear in
|
205
|
+
# the order by clause of a query.
|
206
|
+
#
|
207
|
+
# Can contain fewer values than specified in the order by clause.
|
208
|
+
# @!attribute [rw] before
|
209
|
+
# @return [true, false]
|
210
|
+
# If the position is just before or just after the given values, relative
|
211
|
+
# to the sort order defined by the query.
|
212
|
+
class Cursor; end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
@@ -0,0 +1,167 @@
|
|
1
|
+
# Copyright 2017 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
|
+
module Google
|
16
|
+
module Firestore
|
17
|
+
module V1beta1
|
18
|
+
# A write on a document.
|
19
|
+
# @!attribute [rw] update
|
20
|
+
# @return [Google::Firestore::V1beta1::Document]
|
21
|
+
# A document to write.
|
22
|
+
# @!attribute [rw] delete
|
23
|
+
# @return [String]
|
24
|
+
# A document name to delete. In the format:
|
25
|
+
# +projects/{project_id}/databases/{database_id}/documents/{document_path}+.
|
26
|
+
# @!attribute [rw] transform
|
27
|
+
# @return [Google::Firestore::V1beta1::DocumentTransform]
|
28
|
+
# Applies a tranformation to a document.
|
29
|
+
# At most one +transform+ per document is allowed in a given request.
|
30
|
+
# An +update+ cannot follow a +transform+ on the same document in a given
|
31
|
+
# request.
|
32
|
+
# @!attribute [rw] update_mask
|
33
|
+
# @return [Google::Firestore::V1beta1::DocumentMask]
|
34
|
+
# The fields to update in this write.
|
35
|
+
#
|
36
|
+
# This field can be set only when the operation is +update+.
|
37
|
+
# None of the field paths in the mask may contain a reserved name.
|
38
|
+
# If the document exists on the server and has fields not referenced in the
|
39
|
+
# mask, they are left unchanged.
|
40
|
+
# Fields referenced in the mask, but not present in the input document, are
|
41
|
+
# deleted from the document on the server.
|
42
|
+
# The field paths in this mask must not contain a reserved field name.
|
43
|
+
# @!attribute [rw] current_document
|
44
|
+
# @return [Google::Firestore::V1beta1::Precondition]
|
45
|
+
# An optional precondition on the document.
|
46
|
+
#
|
47
|
+
# The write will fail if this is set and not met by the target document.
|
48
|
+
class Write; end
|
49
|
+
|
50
|
+
# A transformation of a document.
|
51
|
+
# @!attribute [rw] document
|
52
|
+
# @return [String]
|
53
|
+
# The name of the document to transform.
|
54
|
+
# @!attribute [rw] field_transforms
|
55
|
+
# @return [Array<Google::Firestore::V1beta1::DocumentTransform::FieldTransform>]
|
56
|
+
# The list of transformations to apply to the fields of the document, in
|
57
|
+
# order.
|
58
|
+
class DocumentTransform
|
59
|
+
# A transformation of a field of the document.
|
60
|
+
# @!attribute [rw] field_path
|
61
|
+
# @return [String]
|
62
|
+
# The path of the field. See {Google::Firestore::V1beta1::Document#fields Document#fields} for the field path syntax
|
63
|
+
# reference.
|
64
|
+
# @!attribute [rw] set_to_server_value
|
65
|
+
# @return [Google::Firestore::V1beta1::DocumentTransform::FieldTransform::ServerValue]
|
66
|
+
# Sets the field to the given server value.
|
67
|
+
class FieldTransform
|
68
|
+
# A value that is calculated by the server.
|
69
|
+
module ServerValue
|
70
|
+
# Unspecified. This value must not be used.
|
71
|
+
SERVER_VALUE_UNSPECIFIED = 0
|
72
|
+
|
73
|
+
# The time at which the server processed the request.
|
74
|
+
REQUEST_TIME = 1
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# The result of applying a write.
|
80
|
+
# @!attribute [rw] update_time
|
81
|
+
# @return [Google::Protobuf::Timestamp]
|
82
|
+
# The last update time of the document after applying the write. Not set
|
83
|
+
# after a +delete+.
|
84
|
+
#
|
85
|
+
# If the write did not actually change the document, this will be the
|
86
|
+
# previous update_time.
|
87
|
+
# @!attribute [rw] transform_results
|
88
|
+
# @return [Array<Google::Firestore::V1beta1::Value>]
|
89
|
+
# The results of applying each {Google::Firestore::V1beta1::DocumentTransform::FieldTransform DocumentTransform::FieldTransform}, in the
|
90
|
+
# same order.
|
91
|
+
class WriteResult; end
|
92
|
+
|
93
|
+
# A {Google::Firestore::V1beta1::Document Document} has changed.
|
94
|
+
#
|
95
|
+
# May be the result of multiple {Google::Firestore::V1beta1::Write Writes}, including deletes, that
|
96
|
+
# ultimately resulted in a new value for the {Google::Firestore::V1beta1::Document Document}.
|
97
|
+
#
|
98
|
+
# Multiple {Google::Firestore::V1beta1::DocumentChange DocumentChange} messages may be returned for the same logical
|
99
|
+
# change, if multiple targets are affected.
|
100
|
+
# @!attribute [rw] document
|
101
|
+
# @return [Google::Firestore::V1beta1::Document]
|
102
|
+
# The new state of the {Google::Firestore::V1beta1::Document Document}.
|
103
|
+
#
|
104
|
+
# If +mask+ is set, contains only fields that were updated or added.
|
105
|
+
# @!attribute [rw] target_ids
|
106
|
+
# @return [Array<Integer>]
|
107
|
+
# A set of target IDs of targets that match this document.
|
108
|
+
# @!attribute [rw] removed_target_ids
|
109
|
+
# @return [Array<Integer>]
|
110
|
+
# A set of target IDs for targets that no longer match this document.
|
111
|
+
class DocumentChange; end
|
112
|
+
|
113
|
+
# A {Google::Firestore::V1beta1::Document Document} has been deleted.
|
114
|
+
#
|
115
|
+
# May be the result of multiple {Google::Firestore::V1beta1::Write Writes}, including updates, the
|
116
|
+
# last of which deleted the {Google::Firestore::V1beta1::Document Document}.
|
117
|
+
#
|
118
|
+
# Multiple {Google::Firestore::V1beta1::DocumentDelete DocumentDelete} messages may be returned for the same logical
|
119
|
+
# delete, if multiple targets are affected.
|
120
|
+
# @!attribute [rw] document
|
121
|
+
# @return [String]
|
122
|
+
# The resource name of the {Google::Firestore::V1beta1::Document Document} that was deleted.
|
123
|
+
# @!attribute [rw] removed_target_ids
|
124
|
+
# @return [Array<Integer>]
|
125
|
+
# A set of target IDs for targets that previously matched this entity.
|
126
|
+
# @!attribute [rw] read_time
|
127
|
+
# @return [Google::Protobuf::Timestamp]
|
128
|
+
# The read timestamp at which the delete was observed.
|
129
|
+
#
|
130
|
+
# Greater or equal to the +commit_time+ of the delete.
|
131
|
+
class DocumentDelete; end
|
132
|
+
|
133
|
+
# A {Google::Firestore::V1beta1::Document Document} has been removed from the view of the targets.
|
134
|
+
#
|
135
|
+
# Sent if the document is no longer relevant to a target and is out of view.
|
136
|
+
# Can be sent instead of a DocumentDelete or a DocumentChange if the server
|
137
|
+
# can not send the new value of the document.
|
138
|
+
#
|
139
|
+
# Multiple {Google::Firestore::V1beta1::DocumentRemove DocumentRemove} messages may be returned for the same logical
|
140
|
+
# write or delete, if multiple targets are affected.
|
141
|
+
# @!attribute [rw] document
|
142
|
+
# @return [String]
|
143
|
+
# The resource name of the {Google::Firestore::V1beta1::Document Document} that has gone out of view.
|
144
|
+
# @!attribute [rw] removed_target_ids
|
145
|
+
# @return [Array<Integer>]
|
146
|
+
# A set of target IDs for targets that previously matched this document.
|
147
|
+
# @!attribute [rw] read_time
|
148
|
+
# @return [Google::Protobuf::Timestamp]
|
149
|
+
# The read timestamp at which the remove was observed.
|
150
|
+
#
|
151
|
+
# Greater or equal to the +commit_time+ of the change/delete/remove.
|
152
|
+
class DocumentRemove; end
|
153
|
+
|
154
|
+
# A digest of all the documents that match a given target.
|
155
|
+
# @!attribute [rw] target_id
|
156
|
+
# @return [Integer]
|
157
|
+
# The target ID to which this filter applies.
|
158
|
+
# @!attribute [rw] count
|
159
|
+
# @return [Integer]
|
160
|
+
# The total count of documents that match {Google::Firestore::V1beta1::ExistenceFilter#target_id Target_id}.
|
161
|
+
#
|
162
|
+
# If different from the count of documents in the client that match, the
|
163
|
+
# client must manually determine which documents no longer match the target.
|
164
|
+
class ExistenceFilter; end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
# Copyright 2017 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
|
+
module Google
|
16
|
+
module Protobuf
|
17
|
+
# +Any+ contains an arbitrary serialized protocol buffer message along with a
|
18
|
+
# URL that describes the type of the serialized message.
|
19
|
+
#
|
20
|
+
# Protobuf library provides support to pack/unpack Any values in the form
|
21
|
+
# of utility functions or additional generated methods of the Any type.
|
22
|
+
#
|
23
|
+
# Example 1: Pack and unpack a message in C++.
|
24
|
+
#
|
25
|
+
# Foo foo = ...;
|
26
|
+
# Any any;
|
27
|
+
# any.PackFrom(foo);
|
28
|
+
# ...
|
29
|
+
# if (any.UnpackTo(&foo)) {
|
30
|
+
# ...
|
31
|
+
# }
|
32
|
+
#
|
33
|
+
# Example 2: Pack and unpack a message in Java.
|
34
|
+
#
|
35
|
+
# Foo foo = ...;
|
36
|
+
# Any any = Any.pack(foo);
|
37
|
+
# ...
|
38
|
+
# if (any.is(Foo.class)) {
|
39
|
+
# foo = any.unpack(Foo.class);
|
40
|
+
# }
|
41
|
+
#
|
42
|
+
# Example 3: Pack and unpack a message in Python.
|
43
|
+
#
|
44
|
+
# foo = Foo(...)
|
45
|
+
# any = Any()
|
46
|
+
# any.Pack(foo)
|
47
|
+
# ...
|
48
|
+
# if any.Is(Foo.DESCRIPTOR):
|
49
|
+
# any.Unpack(foo)
|
50
|
+
# ...
|
51
|
+
#
|
52
|
+
# Example 4: Pack and unpack a message in Go
|
53
|
+
#
|
54
|
+
# foo := &pb.Foo{...}
|
55
|
+
# any, err := ptypes.MarshalAny(foo)
|
56
|
+
# ...
|
57
|
+
# foo := &pb.Foo{}
|
58
|
+
# if err := ptypes.UnmarshalAny(any, foo); err != nil {
|
59
|
+
# ...
|
60
|
+
# }
|
61
|
+
#
|
62
|
+
# The pack methods provided by protobuf library will by default use
|
63
|
+
# 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
64
|
+
# methods only use the fully qualified type name after the last '/'
|
65
|
+
# in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
66
|
+
# name "y.z".
|
67
|
+
#
|
68
|
+
#
|
69
|
+
# = JSON
|
70
|
+
#
|
71
|
+
# The JSON representation of an +Any+ value uses the regular
|
72
|
+
# representation of the deserialized, embedded message, with an
|
73
|
+
# additional field +@type+ which contains the type URL. Example:
|
74
|
+
#
|
75
|
+
# package google.profile;
|
76
|
+
# message Person {
|
77
|
+
# string first_name = 1;
|
78
|
+
# string last_name = 2;
|
79
|
+
# }
|
80
|
+
#
|
81
|
+
# {
|
82
|
+
# "@type": "type.googleapis.com/google.profile.Person",
|
83
|
+
# "firstName": <string>,
|
84
|
+
# "lastName": <string>
|
85
|
+
# }
|
86
|
+
#
|
87
|
+
# If the embedded message type is well-known and has a custom JSON
|
88
|
+
# representation, that representation will be embedded adding a field
|
89
|
+
# +value+ which holds the custom JSON in addition to the +@type+
|
90
|
+
# field. Example (for message {Google::Protobuf::Duration}):
|
91
|
+
#
|
92
|
+
# {
|
93
|
+
# "@type": "type.googleapis.com/google.protobuf.Duration",
|
94
|
+
# "value": "1.212s"
|
95
|
+
# }
|
96
|
+
# @!attribute [rw] type_url
|
97
|
+
# @return [String]
|
98
|
+
# A URL/resource name whose content describes the type of the
|
99
|
+
# serialized protocol buffer message.
|
100
|
+
#
|
101
|
+
# For URLs which use the scheme +http+, +https+, or no scheme, the
|
102
|
+
# following restrictions and interpretations apply:
|
103
|
+
#
|
104
|
+
# * If no scheme is provided, +https+ is assumed.
|
105
|
+
# * The last segment of the URL's path must represent the fully
|
106
|
+
# qualified name of the type (as in +path/google.protobuf.Duration+).
|
107
|
+
# The name should be in a canonical form (e.g., leading "." is
|
108
|
+
# not accepted).
|
109
|
+
# * An HTTP GET on the URL must yield a {Google::Protobuf::Type}
|
110
|
+
# value in binary format, or produce an error.
|
111
|
+
# * Applications are allowed to cache lookup results based on the
|
112
|
+
# URL, or have them precompiled into a binary to avoid any
|
113
|
+
# lookup. Therefore, binary compatibility needs to be preserved
|
114
|
+
# on changes to types. (Use versioned type names to manage
|
115
|
+
# breaking changes.)
|
116
|
+
#
|
117
|
+
# Schemes other than +http+, +https+ (or the empty scheme) might be
|
118
|
+
# used with implementation specific semantics.
|
119
|
+
# @!attribute [rw] value
|
120
|
+
# @return [String]
|
121
|
+
# Must be a valid serialized protocol buffer of the above specified type.
|
122
|
+
class Any; end
|
123
|
+
end
|
124
|
+
end
|