xref: /aosp_15_r20/external/googleapis/google/datastore/v1beta3/entity.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2018 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
15syntax = "proto3";
16
17package google.datastore.v1beta3;
18
19import "google/api/annotations.proto";
20import "google/protobuf/struct.proto";
21import "google/protobuf/timestamp.proto";
22import "google/type/latlng.proto";
23
24option csharp_namespace = "Google.Cloud.Datastore.V1Beta3";
25option go_package = "google.golang.org/genproto/googleapis/datastore/v1beta3;datastore";
26option java_multiple_files = true;
27option java_outer_classname = "EntityProto";
28option java_package = "com.google.datastore.v1beta3";
29option php_namespace = "Google\\Cloud\\Datastore\\V1beta3";
30option ruby_package = "Google::Cloud::Datastore::V1beta3";
31
32// A partition ID identifies a grouping of entities. The grouping is always
33// by project and namespace, however the namespace ID may be empty.
34//
35// A partition ID contains several dimensions:
36// project ID and namespace ID.
37//
38// Partition dimensions:
39//
40// - May be `""`.
41// - Must be valid UTF-8 bytes.
42// - Must have values that match regex `[A-Za-z\d\.\-_]{1,100}`
43// If the value of any dimension matches regex `__.*__`, the partition is
44// reserved/read-only.
45// A reserved/read-only partition ID is forbidden in certain documented
46// contexts.
47//
48// Foreign partition IDs (in which the project ID does
49// not match the context project ID ) are discouraged.
50// Reads and writes of foreign partition IDs may fail if the project is not in
51// an active state.
52message PartitionId {
53  // The ID of the project to which the entities belong.
54  string project_id = 2;
55
56  // If not empty, the ID of the namespace to which the entities belong.
57  string namespace_id = 4;
58}
59
60// A unique identifier for an entity.
61// If a key's partition ID or any of its path kinds or names are
62// reserved/read-only, the key is reserved/read-only.
63// A reserved/read-only key is forbidden in certain documented contexts.
64message Key {
65  // A (kind, ID/name) pair used to construct a key path.
66  //
67  // If either name or ID is set, the element is complete.
68  // If neither is set, the element is incomplete.
69  message PathElement {
70    // The kind of the entity.
71    // A kind matching regex `__.*__` is reserved/read-only.
72    // A kind must not contain more than 1500 bytes when UTF-8 encoded.
73    // Cannot be `""`.
74    string kind = 1;
75
76    // The type of ID.
77    oneof id_type {
78      // The auto-allocated ID of the entity.
79      // Never equal to zero. Values less than zero are discouraged and may not
80      // be supported in the future.
81      int64 id = 2;
82
83      // The name of the entity.
84      // A name matching regex `__.*__` is reserved/read-only.
85      // A name must not be more than 1500 bytes when UTF-8 encoded.
86      // Cannot be `""`.
87      string name = 3;
88    }
89  }
90
91  // Entities are partitioned into subsets, currently identified by a project
92  // ID and namespace ID.
93  // Queries are scoped to a single partition.
94  PartitionId partition_id = 1;
95
96  // The entity path.
97  // An entity path consists of one or more elements composed of a kind and a
98  // string or numerical identifier, which identify entities. The first
99  // element identifies a _root entity_, the second element identifies
100  // a _child_ of the root entity, the third element identifies a child of the
101  // second entity, and so forth. The entities identified by all prefixes of
102  // the path are called the element's _ancestors_.
103  //
104  // An entity path is always fully complete: *all* of the entity's ancestors
105  // are required to be in the path along with the entity identifier itself.
106  // The only exception is that in some documented cases, the identifier in the
107  // last path element (for the entity) itself may be omitted. For example,
108  // the last path element of the key of `Mutation.insert` may have no
109  // identifier.
110  //
111  // A path can never be empty, and a path can have at most 100 elements.
112  repeated PathElement path = 2;
113}
114
115// An array value.
116message ArrayValue {
117  // Values in the array.
118  // The order of this array may not be preserved if it contains a mix of
119  // indexed and unindexed values.
120  repeated Value values = 1;
121}
122
123// A message that can hold any of the supported value types and associated
124// metadata.
125message Value {
126  // Must have a value set.
127  oneof value_type {
128    // A null value.
129    google.protobuf.NullValue null_value = 11;
130
131    // A boolean value.
132    bool boolean_value = 1;
133
134    // An integer value.
135    int64 integer_value = 2;
136
137    // A double value.
138    double double_value = 3;
139
140    // A timestamp value.
141    // When stored in the Datastore, precise only to microseconds;
142    // any additional precision is rounded down.
143    google.protobuf.Timestamp timestamp_value = 10;
144
145    // A key value.
146    Key key_value = 5;
147
148    // A UTF-8 encoded string value.
149    // When `exclude_from_indexes` is false (it is indexed), may have at most
150    // 1500 bytes. Otherwise, may be set to at most 1,000,000 bytes.
151    string string_value = 17;
152
153    // A blob value.
154    // May have at most 1,000,000 bytes.
155    // When `exclude_from_indexes` is false, may have at most 1500 bytes.
156    // In JSON requests, must be base64-encoded.
157    bytes blob_value = 18;
158
159    // A geo point value representing a point on the surface of Earth.
160    google.type.LatLng geo_point_value = 8;
161
162    // An entity value.
163    //
164    // - May have no key.
165    // - May have a key with an incomplete key path.
166    // - May have a reserved/read-only key.
167    Entity entity_value = 6;
168
169    // An array value.
170    // Cannot contain another array value.
171    // A `Value` instance that sets field `array_value` must not set fields
172    // `meaning` or `exclude_from_indexes`.
173    ArrayValue array_value = 9;
174  }
175
176  // The `meaning` field should only be populated for backwards compatibility.
177  int32 meaning = 14;
178
179  // If the value should be excluded from all indexes including those defined
180  // explicitly.
181  bool exclude_from_indexes = 19;
182}
183
184// A Datastore data object.
185//
186// An entity is limited to 1 megabyte when stored. That _roughly_
187// corresponds to a limit of 1 megabyte for the serialized form of this
188// message.
189message Entity {
190  // The entity's key.
191  //
192  // An entity must have a key, unless otherwise documented (for example,
193  // an entity in `Value.entity_value` may have no key).
194  // An entity's kind is its key path's last element's kind,
195  // or null if it has no key.
196  Key key = 1;
197
198  // The entity's properties.
199  // The map's keys are property names.
200  // A property name matching regex `__.*__` is reserved.
201  // A reserved property name is forbidden in certain documented contexts.
202  // The name must not contain more than 500 characters.
203  // The name cannot be `""`.
204  map<string, Value> properties = 3;
205}
206