google-cloud-datastore 0.21.0 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,187 @@
1
+ # Copyright 2016 Google Inc. All rights reserved.
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
+ # http://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 Datastore
17
+ module V1
18
+ # A partition ID identifies a grouping of entities. The grouping is always
19
+ # by project and namespace, however the namespace ID may be empty.
20
+ #
21
+ # A partition ID contains several dimensions:
22
+ # project ID and namespace ID.
23
+ #
24
+ # Partition dimensions:
25
+ #
26
+ # - May be +""+.
27
+ # - Must be valid UTF-8 bytes.
28
+ # - Must have values that match regex +[A-Za-z\d\.\-_]{1,100}+
29
+ # If the value of any dimension matches regex +__.*__+, the partition is
30
+ # reserved/read-only.
31
+ # A reserved/read-only partition ID is forbidden in certain documented
32
+ # contexts.
33
+ #
34
+ # Foreign partition IDs (in which the project ID does
35
+ # not match the context project ID ) are discouraged.
36
+ # Reads and writes of foreign partition IDs may fail if the project is not in an active state.
37
+ # @!attribute [rw] project_id
38
+ # @return [String]
39
+ # The ID of the project to which the entities belong.
40
+ # @!attribute [rw] namespace_id
41
+ # @return [String]
42
+ # If not empty, the ID of the namespace to which the entities belong.
43
+ class PartitionId; end
44
+
45
+ # A unique identifier for an entity.
46
+ # If a key's partition ID or any of its path kinds or names are
47
+ # reserved/read-only, the key is reserved/read-only.
48
+ # A reserved/read-only key is forbidden in certain documented contexts.
49
+ # @!attribute [rw] partition_id
50
+ # @return [Google::Datastore::V1::PartitionId]
51
+ # Entities are partitioned into subsets, currently identified by a project
52
+ # ID and namespace ID.
53
+ # Queries are scoped to a single partition.
54
+ # @!attribute [rw] path
55
+ # @return [Array<Google::Datastore::V1::Key::PathElement>]
56
+ # The entity path.
57
+ # An entity path consists of one or more elements composed of a kind and a
58
+ # string or numerical identifier, which identify entities. The first
59
+ # element identifies a _root entity_, the second element identifies
60
+ # a _child_ of the root entity, the third element identifies a child of the
61
+ # second entity, and so forth. The entities identified by all prefixes of
62
+ # the path are called the element's _ancestors_.
63
+ #
64
+ # An entity path is always fully complete: *all* of the entity's ancestors
65
+ # are required to be in the path along with the entity identifier itself.
66
+ # The only exception is that in some documented cases, the identifier in the
67
+ # last path element (for the entity) itself may be omitted. For example,
68
+ # the last path element of the key of +Mutation.insert+ may have no
69
+ # identifier.
70
+ #
71
+ # A path can never be empty, and a path can have at most 100 elements.
72
+ class Key
73
+ # A (kind, ID/name) pair used to construct a key path.
74
+ #
75
+ # If either name or ID is set, the element is complete.
76
+ # If neither is set, the element is incomplete.
77
+ # @!attribute [rw] kind
78
+ # @return [String]
79
+ # The kind of the entity.
80
+ # A kind matching regex +__.*__+ is reserved/read-only.
81
+ # A kind must not contain more than 1500 bytes when UTF-8 encoded.
82
+ # Cannot be +""+.
83
+ # @!attribute [rw] id
84
+ # @return [Integer]
85
+ # The auto-allocated ID of the entity.
86
+ # Never equal to zero. Values less than zero are discouraged and may not
87
+ # be supported in the future.
88
+ # @!attribute [rw] name
89
+ # @return [String]
90
+ # The name of the entity.
91
+ # A name matching regex +__.*__+ is reserved/read-only.
92
+ # A name must not be more than 1500 bytes when UTF-8 encoded.
93
+ # Cannot be +""+.
94
+ class PathElement; end
95
+ end
96
+
97
+ # An array value.
98
+ # @!attribute [rw] values
99
+ # @return [Array<Google::Datastore::V1::Value>]
100
+ # Values in the array.
101
+ # The order of this array may not be preserved if it contains a mix of
102
+ # indexed and unindexed values.
103
+ class ArrayValue; end
104
+
105
+ # A message that can hold any of the supported value types and associated
106
+ # metadata.
107
+ # @!attribute [rw] null_value
108
+ # @return [Google::Protobuf::NullValue]
109
+ # A null value.
110
+ # @!attribute [rw] boolean_value
111
+ # @return [true, false]
112
+ # A boolean value.
113
+ # @!attribute [rw] integer_value
114
+ # @return [Integer]
115
+ # An integer value.
116
+ # @!attribute [rw] double_value
117
+ # @return [Float]
118
+ # A double value.
119
+ # @!attribute [rw] timestamp_value
120
+ # @return [Google::Protobuf::Timestamp]
121
+ # A timestamp value.
122
+ # When stored in the Datastore, precise only to microseconds;
123
+ # any additional precision is rounded down.
124
+ # @!attribute [rw] key_value
125
+ # @return [Google::Datastore::V1::Key]
126
+ # A key value.
127
+ # @!attribute [rw] string_value
128
+ # @return [String]
129
+ # A UTF-8 encoded string value.
130
+ # When +exclude_from_indexes+ is false (it is indexed) , may have at most 1500 bytes.
131
+ # Otherwise, may be set to at least 1,000,000 bytes.
132
+ # @!attribute [rw] blob_value
133
+ # @return [String]
134
+ # A blob value.
135
+ # May have at most 1,000,000 bytes.
136
+ # When +exclude_from_indexes+ is false, may have at most 1500 bytes.
137
+ # In JSON requests, must be base64-encoded.
138
+ # @!attribute [rw] geo_point_value
139
+ # @return [Google::Type::LatLng]
140
+ # A geo point value representing a point on the surface of Earth.
141
+ # @!attribute [rw] entity_value
142
+ # @return [Google::Datastore::V1::Entity]
143
+ # An entity value.
144
+ #
145
+ # - May have no key.
146
+ # - May have a key with an incomplete key path.
147
+ # - May have a reserved/read-only key.
148
+ # @!attribute [rw] array_value
149
+ # @return [Google::Datastore::V1::ArrayValue]
150
+ # An array value.
151
+ # Cannot contain another array value.
152
+ # A +Value+ instance that sets field +array_value+ must not set fields
153
+ # +meaning+ or +exclude_from_indexes+.
154
+ # @!attribute [rw] meaning
155
+ # @return [Integer]
156
+ # The +meaning+ field should only be populated for backwards compatibility.
157
+ # @!attribute [rw] exclude_from_indexes
158
+ # @return [true, false]
159
+ # If the value should be excluded from all indexes including those defined
160
+ # explicitly.
161
+ class Value; end
162
+
163
+ # A Datastore data object.
164
+ #
165
+ # An entity is limited to 1 megabyte when stored. That _roughly_
166
+ # corresponds to a limit of 1 megabyte for the serialized form of this
167
+ # message.
168
+ # @!attribute [rw] key
169
+ # @return [Google::Datastore::V1::Key]
170
+ # The entity's key.
171
+ #
172
+ # An entity must have a key, unless otherwise documented (for example,
173
+ # an entity in +Value.entity_value+ may have no key).
174
+ # An entity's kind is its key path's last element's kind,
175
+ # or null if it has no key.
176
+ # @!attribute [rw] properties
177
+ # @return [Hash{String => Google::Datastore::V1::Value}]
178
+ # The entity's properties.
179
+ # The map's keys are property names.
180
+ # A property name matching regex +__.*__+ is reserved.
181
+ # A reserved property name is forbidden in certain documented contexts.
182
+ # The name must not contain more than 500 characters.
183
+ # The name cannot be +""+.
184
+ class Entity; end
185
+ end
186
+ end
187
+ end
@@ -0,0 +1,292 @@
1
+ # Copyright 2016 Google Inc. All rights reserved.
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
+ # http://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 Datastore
17
+ module V1
18
+ # The result of fetching an entity from Datastore.
19
+ # @!attribute [rw] entity
20
+ # @return [Google::Datastore::V1::Entity]
21
+ # The resulting entity.
22
+ # @!attribute [rw] version
23
+ # @return [Integer]
24
+ # The version of the entity, a strictly positive number that monotonically
25
+ # increases with changes to the entity.
26
+ #
27
+ # This field is set for +FULL+ entity
28
+ # results.
29
+ #
30
+ # For Missing entities in +LookupResponse+, this
31
+ # is the version of the snapshot that was used to look up the entity, and it
32
+ # is always set except for eventually consistent reads.
33
+ # @!attribute [rw] cursor
34
+ # @return [String]
35
+ # A cursor that points to the position after the result entity.
36
+ # Set only when the +EntityResult+ is part of a +QueryResultBatch+ message.
37
+ class EntityResult
38
+ # Specifies what data the 'entity' field contains.
39
+ # A +ResultType+ is either implied (for example, in +LookupResponse.missing+
40
+ # from +datastore.proto+, it is always +KEY_ONLY+) or specified by context
41
+ # (for example, in message +QueryResultBatch+, field +entity_result_type+
42
+ # specifies a +ResultType+ for all the values in field +entity_results+).
43
+ module ResultType
44
+ # Unspecified. This value is never used.
45
+ RESULT_TYPE_UNSPECIFIED = 0
46
+
47
+ # The key and properties.
48
+ FULL = 1
49
+
50
+ # A projected subset of properties. The entity may have no key.
51
+ PROJECTION = 2
52
+
53
+ # Only the key.
54
+ KEY_ONLY = 3
55
+ end
56
+ end
57
+
58
+ # A query for entities.
59
+ # @!attribute [rw] projection
60
+ # @return [Array<Google::Datastore::V1::Projection>]
61
+ # The projection to return. Defaults to returning all properties.
62
+ # @!attribute [rw] kind
63
+ # @return [Array<Google::Datastore::V1::KindExpression>]
64
+ # The kinds to query (if empty, returns entities of all kinds).
65
+ # Currently at most 1 kind may be specified.
66
+ # @!attribute [rw] filter
67
+ # @return [Google::Datastore::V1::Filter]
68
+ # The filter to apply.
69
+ # @!attribute [rw] order
70
+ # @return [Array<Google::Datastore::V1::PropertyOrder>]
71
+ # The order to apply to the query results (if empty, order is unspecified).
72
+ # @!attribute [rw] distinct_on
73
+ # @return [Array<Google::Datastore::V1::PropertyReference>]
74
+ # The properties to make distinct. The query results will contain the first
75
+ # result for each distinct combination of values for the given properties
76
+ # (if empty, all results are returned).
77
+ # @!attribute [rw] start_cursor
78
+ # @return [String]
79
+ # A starting point for the query results. Query cursors are
80
+ # returned in query result batches and
81
+ # {can only be used to continue the same query}[https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets].
82
+ # @!attribute [rw] end_cursor
83
+ # @return [String]
84
+ # An ending point for the query results. Query cursors are
85
+ # returned in query result batches and
86
+ # {can only be used to limit the same query}[https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets].
87
+ # @!attribute [rw] offset
88
+ # @return [Integer]
89
+ # The number of results to skip. Applies before limit, but after all other
90
+ # constraints. Optional. Must be >= 0 if specified.
91
+ # @!attribute [rw] limit
92
+ # @return [Google::Protobuf::Int32Value]
93
+ # The maximum number of results to return. Applies after all other
94
+ # constraints. Optional.
95
+ # Unspecified is interpreted as no limit.
96
+ # Must be >= 0 if specified.
97
+ class Query; end
98
+
99
+ # A representation of a kind.
100
+ # @!attribute [rw] name
101
+ # @return [String]
102
+ # The name of the kind.
103
+ class KindExpression; end
104
+
105
+ # A reference to a property relative to the kind expressions.
106
+ # @!attribute [rw] name
107
+ # @return [String]
108
+ # The name of the property.
109
+ # If name includes "."s, it may be interpreted as a property name path.
110
+ class PropertyReference; end
111
+
112
+ # A representation of a property in a projection.
113
+ # @!attribute [rw] property
114
+ # @return [Google::Datastore::V1::PropertyReference]
115
+ # The property to project.
116
+ class Projection; end
117
+
118
+ # The desired order for a specific property.
119
+ # @!attribute [rw] property
120
+ # @return [Google::Datastore::V1::PropertyReference]
121
+ # The property to order by.
122
+ # @!attribute [rw] direction
123
+ # @return [Google::Datastore::V1::PropertyOrder::Direction]
124
+ # The direction to order by. Defaults to +ASCENDING+.
125
+ class PropertyOrder
126
+ # The sort direction.
127
+ module Direction
128
+ # Unspecified. This value must not be used.
129
+ DIRECTION_UNSPECIFIED = 0
130
+
131
+ # Ascending.
132
+ ASCENDING = 1
133
+
134
+ # Descending.
135
+ DESCENDING = 2
136
+ end
137
+ end
138
+
139
+ # A holder for any type of filter.
140
+ # @!attribute [rw] composite_filter
141
+ # @return [Google::Datastore::V1::CompositeFilter]
142
+ # A composite filter.
143
+ # @!attribute [rw] property_filter
144
+ # @return [Google::Datastore::V1::PropertyFilter]
145
+ # A filter on a property.
146
+ class Filter; end
147
+
148
+ # A filter that merges multiple other filters using the given operator.
149
+ # @!attribute [rw] op
150
+ # @return [Google::Datastore::V1::CompositeFilter::Operator]
151
+ # The operator for combining multiple filters.
152
+ # @!attribute [rw] filters
153
+ # @return [Array<Google::Datastore::V1::Filter>]
154
+ # The list of filters to combine.
155
+ # Must contain at least one filter.
156
+ class CompositeFilter
157
+ # A composite filter operator.
158
+ module Operator
159
+ # Unspecified. This value must not be used.
160
+ OPERATOR_UNSPECIFIED = 0
161
+
162
+ # The results are required to satisfy each of the combined filters.
163
+ AND = 1
164
+ end
165
+ end
166
+
167
+ # A filter on a specific property.
168
+ # @!attribute [rw] property
169
+ # @return [Google::Datastore::V1::PropertyReference]
170
+ # The property to filter by.
171
+ # @!attribute [rw] op
172
+ # @return [Google::Datastore::V1::PropertyFilter::Operator]
173
+ # The operator to filter by.
174
+ # @!attribute [rw] value
175
+ # @return [Google::Datastore::V1::Value]
176
+ # The value to compare the property to.
177
+ class PropertyFilter
178
+ # A property filter operator.
179
+ module Operator
180
+ # Unspecified. This value must not be used.
181
+ OPERATOR_UNSPECIFIED = 0
182
+
183
+ # Less than.
184
+ LESS_THAN = 1
185
+
186
+ # Less than or equal.
187
+ LESS_THAN_OR_EQUAL = 2
188
+
189
+ # Greater than.
190
+ GREATER_THAN = 3
191
+
192
+ # Greater than or equal.
193
+ GREATER_THAN_OR_EQUAL = 4
194
+
195
+ # Equal.
196
+ EQUAL = 5
197
+
198
+ # Has ancestor.
199
+ HAS_ANCESTOR = 11
200
+ end
201
+ end
202
+
203
+ # A {GQL query}[https://cloud.google.com/datastore/docs/apis/gql/gql_reference].
204
+ # @!attribute [rw] query_string
205
+ # @return [String]
206
+ # A string of the format described
207
+ # {here}[https://cloud.google.com/datastore/docs/apis/gql/gql_reference].
208
+ # @!attribute [rw] allow_literals
209
+ # @return [true, false]
210
+ # When false, the query string must not contain any literals and instead must
211
+ # bind all values. For example,
212
+ # +SELECT * FROM Kind WHERE a = 'string literal'+ is not allowed, while
213
+ # +SELECT * FROM Kind WHERE a = @value+ is.
214
+ # @!attribute [rw] named_bindings
215
+ # @return [Hash{String => Google::Datastore::V1::GqlQueryParameter}]
216
+ # For each non-reserved named binding site in the query string, there must be
217
+ # a named parameter with that name, but not necessarily the inverse.
218
+ #
219
+ # Key must match regex +[A-Za-z_$][A-Za-z_$0-9]*+, must not match regex
220
+ # +__.*__+, and must not be +""+.
221
+ # @!attribute [rw] positional_bindings
222
+ # @return [Array<Google::Datastore::V1::GqlQueryParameter>]
223
+ # Numbered binding site @1 references the first numbered parameter,
224
+ # effectively using 1-based indexing, rather than the usual 0.
225
+ #
226
+ # For each binding site numbered i in +query_string+, there must be an i-th
227
+ # numbered parameter. The inverse must also be true.
228
+ class GqlQuery; end
229
+
230
+ # A binding parameter for a GQL query.
231
+ # @!attribute [rw] value
232
+ # @return [Google::Datastore::V1::Value]
233
+ # A value parameter.
234
+ # @!attribute [rw] cursor
235
+ # @return [String]
236
+ # A query cursor. Query cursors are returned in query
237
+ # result batches.
238
+ class GqlQueryParameter; end
239
+
240
+ # A batch of results produced by a query.
241
+ # @!attribute [rw] skipped_results
242
+ # @return [Integer]
243
+ # The number of results skipped, typically because of an offset.
244
+ # @!attribute [rw] skipped_cursor
245
+ # @return [String]
246
+ # A cursor that points to the position after the last skipped result.
247
+ # Will be set when +skipped_results+ != 0.
248
+ # @!attribute [rw] entity_result_type
249
+ # @return [Google::Datastore::V1::EntityResult::ResultType]
250
+ # The result type for every entity in +entity_results+.
251
+ # @!attribute [rw] entity_results
252
+ # @return [Array<Google::Datastore::V1::EntityResult>]
253
+ # The results for this batch.
254
+ # @!attribute [rw] end_cursor
255
+ # @return [String]
256
+ # A cursor that points to the position after the last result in the batch.
257
+ # @!attribute [rw] more_results
258
+ # @return [Google::Datastore::V1::QueryResultBatch::MoreResultsType]
259
+ # The state of the query after the current batch.
260
+ # @!attribute [rw] snapshot_version
261
+ # @return [Integer]
262
+ # The version number of the snapshot this batch was returned from.
263
+ # This applies to the range of results from the query's +start_cursor+ (or
264
+ # the beginning of the query if no cursor was given) to this batch's
265
+ # +end_cursor+ (not the query's +end_cursor+).
266
+ #
267
+ # In a single transaction, subsequent query result batches for the same query
268
+ # can have a greater snapshot version number. Each batch's snapshot version
269
+ # is valid for all preceding batches.
270
+ class QueryResultBatch
271
+ # The possible values for the +more_results+ field.
272
+ module MoreResultsType
273
+ # Unspecified. This value is never used.
274
+ MORE_RESULTS_TYPE_UNSPECIFIED = 0
275
+
276
+ # There may be additional batches to fetch from this query.
277
+ NOT_FINISHED = 1
278
+
279
+ # The query is finished, but there may be more results after the limit.
280
+ MORE_RESULTS_AFTER_LIMIT = 2
281
+
282
+ # The query is finished, but there may be more results after the end
283
+ # cursor.
284
+ MORE_RESULTS_AFTER_CURSOR = 4
285
+
286
+ # The query has been exhausted.
287
+ NO_MORE_RESULTS = 3
288
+ end
289
+ end
290
+ end
291
+ end
292
+ end