| 1 |
// Copyright 2016 Google Inc. |
| 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 |
syntax = "proto3"; |
| 16 |
|
| 17 |
package google.datastore.v1beta3; |
| 18 |
|
| 19 |
import "google/api/annotations.proto"; |
| 20 |
import "google/datastore/v1beta3/entity.proto"; |
| 21 |
import "google/protobuf/wrappers.proto"; |
| 22 |
import "google/type/latlng.proto"; |
| 23 |
|
| 24 |
option csharp_namespace = "Google.Cloud.Datastore.V1Beta3"; |
| 25 |
option go_package = "google.golang.org/genproto/googleapis/datastore/v1beta3;datastore"; |
| 26 |
option java_multiple_files = true; |
| 27 |
option java_outer_classname = "QueryProto"; |
| 28 |
option java_package = "com.google.datastore.v1beta3"; |
| 29 |
|
| 30 |
|
| 31 |
// The result of fetching an entity from Datastore. |
| 32 |
message EntityResult { |
| 33 |
// Specifies what data the 'entity' field contains. |
| 34 |
// A `ResultType` is either implied (for example, in `LookupResponse.missing` |
| 35 |
// from `datastore.proto`, it is always `KEY_ONLY`) or specified by context |
| 36 |
// (for example, in message `QueryResultBatch`, field `entity_result_type` |
| 37 |
// specifies a `ResultType` for all the values in field `entity_results`). |
| 38 |
enum ResultType { |
| 39 |
// Unspecified. This value is never used. |
| 40 |
RESULT_TYPE_UNSPECIFIED = 0; |
| 41 |
|
| 42 |
// The key and properties. |
| 43 |
FULL = 1; |
| 44 |
|
| 45 |
// A projected subset of properties. The entity may have no key. |
| 46 |
PROJECTION = 2; |
| 47 |
|
| 48 |
// Only the key. |
| 49 |
KEY_ONLY = 3; |
| 50 |
} |
| 51 |
|
| 52 |
// The resulting entity. |
| 53 |
Entity entity = 1; |
| 54 |
|
| 55 |
// The version of the entity, a strictly positive number that monotonically |
| 56 |
// increases with changes to the entity. |
| 57 |
// |
| 58 |
// This field is set for [`FULL`][google.datastore.v1beta3.EntityResult.ResultType.FULL] entity |
| 59 |
// results. |
| 60 |
// |
| 61 |
// For [missing][google.datastore.v1beta3.LookupResponse.missing] entities in `LookupResponse`, this |
| 62 |
// is the version of the snapshot that was used to look up the entity, and it |
| 63 |
// is always set except for eventually consistent reads. |
| 64 |
int64 version = 4; |
| 65 |
|
| 66 |
// A cursor that points to the position after the result entity. |
| 67 |
// Set only when the `EntityResult` is part of a `QueryResultBatch` message. |
| 68 |
bytes cursor = 3; |
| 69 |
} |
| 70 |
|
| 71 |
// A query for entities. |
| 72 |
message Query { |
| 73 |
// The projection to return. Defaults to returning all properties. |
| 74 |
repeated Projection projection = 2; |
| 75 |
|
| 76 |
// The kinds to query (if empty, returns entities of all kinds). |
| 77 |
// Currently at most 1 kind may be specified. |
| 78 |
repeated KindExpression kind = 3; |
| 79 |
|
| 80 |
// The filter to apply. |
| 81 |
Filter filter = 4; |
| 82 |
|
| 83 |
// The order to apply to the query results (if empty, order is unspecified). |
| 84 |
repeated PropertyOrder order = 5; |
| 85 |
|
| 86 |
// The properties to make distinct. The query results will contain the first |
| 87 |
// result for each distinct combination of values for the given properties |
| 88 |
// (if empty, all results are returned). |
| 89 |
repeated PropertyReference distinct_on = 6; |
| 90 |
|
| 91 |
// A starting point for the query results. Query cursors are |
| 92 |
// returned in query result batches and |
| 93 |
// [can only be used to continue the same query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets). |
| 94 |
bytes start_cursor = 7; |
| 95 |
|
| 96 |
// An ending point for the query results. Query cursors are |
| 97 |
// returned in query result batches and |
| 98 |
// [can only be used to limit the same query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets). |
| 99 |
bytes end_cursor = 8; |
| 100 |
|
| 101 |
// The number of results to skip. Applies before limit, but after all other |
| 102 |
// constraints. Optional. Must be >= 0 if specified. |
| 103 |
int32 offset = 10; |
| 104 |
|
| 105 |
// The maximum number of results to return. Applies after all other |
| 106 |
// constraints. Optional. |
| 107 |
// Unspecified is interpreted as no limit. |
| 108 |
// Must be >= 0 if specified. |
| 109 |
google.protobuf.Int32Value limit = 12; |
| 110 |
} |
| 111 |
|
| 112 |
// A representation of a kind. |
| 113 |
message KindExpression { |
| 114 |
// The name of the kind. |
| 115 |
string name = 1; |
| 116 |
} |
| 117 |
|
| 118 |
// A reference to a property relative to the kind expressions. |
| 119 |
message PropertyReference { |
| 120 |
// The name of the property. |
| 121 |
// If name includes "."s, it may be interpreted as a property name path. |
| 122 |
string name = 2; |
| 123 |
} |
| 124 |
|
| 125 |
// A representation of a property in a projection. |
| 126 |
message Projection { |
| 127 |
// The property to project. |
| 128 |
PropertyReference property = 1; |
| 129 |
} |
| 130 |
|
| 131 |
// The desired order for a specific property. |
| 132 |
message PropertyOrder { |
| 133 |
// The sort direction. |
| 134 |
enum Direction { |
| 135 |
// Unspecified. This value must not be used. |
| 136 |
DIRECTION_UNSPECIFIED = 0; |
| 137 |
|
| 138 |
// Ascending. |
| 139 |
ASCENDING = 1; |
| 140 |
|
| 141 |
// Descending. |
| 142 |
DESCENDING = 2; |
| 143 |
} |
| 144 |
|
| 145 |
// The property to order by. |
| 146 |
PropertyReference property = 1; |
| 147 |
|
| 148 |
// The direction to order by. Defaults to `ASCENDING`. |
| 149 |
Direction direction = 2; |
| 150 |
} |
| 151 |
|
| 152 |
// A holder for any type of filter. |
| 153 |
message Filter { |
| 154 |
// The type of filter. |
| 155 |
oneof filter_type { |
| 156 |
// A composite filter. |
| 157 |
CompositeFilter composite_filter = 1; |
| 158 |
|
| 159 |
// A filter on a property. |
| 160 |
PropertyFilter property_filter = 2; |
| 161 |
} |
| 162 |
} |
| 163 |
|
| 164 |
// A filter that merges multiple other filters using the given operator. |
| 165 |
message CompositeFilter { |
| 166 |
// A composite filter operator. |
| 167 |
enum Operator { |
| 168 |
// Unspecified. This value must not be used. |
| 169 |
OPERATOR_UNSPECIFIED = 0; |
| 170 |
|
| 171 |
// The results are required to satisfy each of the combined filters. |
| 172 |
AND = 1; |
| 173 |
} |
| 174 |
|
| 175 |
// The operator for combining multiple filters. |
| 176 |
Operator op = 1; |
| 177 |
|
| 178 |
// The list of filters to combine. |
| 179 |
// Must contain at least one filter. |
| 180 |
repeated Filter filters = 2; |
| 181 |
} |
| 182 |
|
| 183 |
// A filter on a specific property. |
| 184 |
message PropertyFilter { |
| 185 |
// A property filter operator. |
| 186 |
enum Operator { |
| 187 |
// Unspecified. This value must not be used. |
| 188 |
OPERATOR_UNSPECIFIED = 0; |
| 189 |
|
| 190 |
// Less than. |
| 191 |
LESS_THAN = 1; |
| 192 |
|
| 193 |
// Less than or equal. |
| 194 |
LESS_THAN_OR_EQUAL = 2; |
| 195 |
|
| 196 |
// Greater than. |
| 197 |
GREATER_THAN = 3; |
| 198 |
|
| 199 |
// Greater than or equal. |
| 200 |
GREATER_THAN_OR_EQUAL = 4; |
| 201 |
|
| 202 |
// Equal. |
| 203 |
EQUAL = 5; |
| 204 |
|
| 205 |
// Has ancestor. |
| 206 |
HAS_ANCESTOR = 11; |
| 207 |
} |
| 208 |
|
| 209 |
// The property to filter by. |
| 210 |
PropertyReference property = 1; |
| 211 |
|
| 212 |
// The operator to filter by. |
| 213 |
Operator op = 2; |
| 214 |
|
| 215 |
// The value to compare the property to. |
| 216 |
Value value = 3; |
| 217 |
} |
| 218 |
|
| 219 |
// A [GQL query](https://cloud.google.com/datastore/docs/apis/gql/gql_reference). |
| 220 |
message GqlQuery { |
| 221 |
// A string of the format described |
| 222 |
// [here](https://cloud.google.com/datastore/docs/apis/gql/gql_reference). |
| 223 |
string query_string = 1; |
| 224 |
|
| 225 |
// When false, the query string must not contain any literals and instead must |
| 226 |
// bind all values. For example, |
| 227 |
// `SELECT * FROM Kind WHERE a = 'string literal'` is not allowed, while |
| 228 |
// `SELECT * FROM Kind WHERE a = @value` is. |
| 229 |
bool allow_literals = 2; |
| 230 |
|
| 231 |
// For each non-reserved named binding site in the query string, there must be |
| 232 |
// a named parameter with that name, but not necessarily the inverse. |
| 233 |
// |
| 234 |
// Key must match regex `[A-Za-z_$][A-Za-z_$0-9]*`, must not match regex |
| 235 |
// `__.*__`, and must not be `""`. |
| 236 |
map<string, GqlQueryParameter> named_bindings = 5; |
| 237 |
|
| 238 |
// Numbered binding site @1 references the first numbered parameter, |
| 239 |
// effectively using 1-based indexing, rather than the usual 0. |
| 240 |
// |
| 241 |
// For each binding site numbered i in `query_string`, there must be an i-th |
| 242 |
// numbered parameter. The inverse must also be true. |
| 243 |
repeated GqlQueryParameter positional_bindings = 4; |
| 244 |
} |
| 245 |
|
| 246 |
// A binding parameter for a GQL query. |
| 247 |
message GqlQueryParameter { |
| 248 |
// The type of parameter. |
| 249 |
oneof parameter_type { |
| 250 |
// A value parameter. |
| 251 |
Value value = 2; |
| 252 |
|
| 253 |
// A query cursor. Query cursors are returned in query |
| 254 |
// result batches. |
| 255 |
bytes cursor = 3; |
| 256 |
} |
| 257 |
} |
| 258 |
|
| 259 |
// A batch of results produced by a query. |
| 260 |
message QueryResultBatch { |
| 261 |
// The possible values for the `more_results` field. |
| 262 |
enum MoreResultsType { |
| 263 |
// Unspecified. This value is never used. |
| 264 |
MORE_RESULTS_TYPE_UNSPECIFIED = 0; |
| 265 |
|
| 266 |
// There may be additional batches to fetch from this query. |
| 267 |
NOT_FINISHED = 1; |
| 268 |
|
| 269 |
// The query is finished, but there may be more results after the limit. |
| 270 |
MORE_RESULTS_AFTER_LIMIT = 2; |
| 271 |
|
| 272 |
// The query is finished, but there may be more results after the end |
| 273 |
// cursor. |
| 274 |
MORE_RESULTS_AFTER_CURSOR = 4; |
| 275 |
|
| 276 |
// The query has been exhausted. |
| 277 |
NO_MORE_RESULTS = 3; |
| 278 |
} |
| 279 |
|
| 280 |
// The number of results skipped, typically because of an offset. |
| 281 |
int32 skipped_results = 6; |
| 282 |
|
| 283 |
// A cursor that points to the position after the last skipped result. |
| 284 |
// Will be set when `skipped_results` != 0. |
| 285 |
bytes skipped_cursor = 3; |
| 286 |
|
| 287 |
// The result type for every entity in `entity_results`. |
| 288 |
EntityResult.ResultType entity_result_type = 1; |
| 289 |
|
| 290 |
// The results for this batch. |
| 291 |
repeated EntityResult entity_results = 2; |
| 292 |
|
| 293 |
// A cursor that points to the position after the last result in the batch. |
| 294 |
bytes end_cursor = 4; |
| 295 |
|
| 296 |
// The state of the query after the current batch. |
| 297 |
MoreResultsType more_results = 5; |
| 298 |
|
| 299 |
// The version number of the snapshot this batch was returned from. |
| 300 |
// This applies to the range of results from the query's `start_cursor` (or |
| 301 |
// the beginning of the query if no cursor was given) to this batch's |
| 302 |
// `end_cursor` (not the query's `end_cursor`). |
| 303 |
// |
| 304 |
// In a single transaction, subsequent query result batches for the same query |
| 305 |
// can have a greater snapshot version number. Each batch's snapshot version |
| 306 |
// is valid for all preceding batches. |
| 307 |
// The value will be zero for eventually consistent queries. |
| 308 |
int64 snapshot_version = 7; |
| 309 |
} |