├── README.md ├── backup ├── .gitignore ├── backup.go ├── datastore.go ├── key.go ├── load.go ├── metadata.go ├── pb │ ├── datastore_v3.pb.go │ └── datastore_v3.proto ├── prop.go └── save.go ├── example ├── .gitignore ├── main.go └── model.go ├── exported-data └── data │ ├── ahZzfm1pZ3JhdGlvbi1zcWwtc2FtcGxlckELEhxfQUVfRGF0YXN0b3JlQWRtaW5fT3BlcmF0aW9uGIGb7gIMCxIWX0FFX0JhY2t1cF9JbmZvcm1hdGlvbhgBDA.Profile.backup_info │ ├── ahZzfm1pZ3JhdGlvbi1zcWwtc2FtcGxlckELEhxfQUVfRGF0YXN0b3JlQWRtaW5fT3BlcmF0aW9uGIGb7gIMCxIWX0FFX0JhY2t1cF9JbmZvcm1hdGlvbhgBDA.backup_info │ └── datastore_backup_datastore_backup_2016_02_07_Profile │ └── 157249940434231075281045461947F │ └── output-0 └── sample-server ├── .gitignore ├── app.yaml └── main.go /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | #### Check the blog post: http://www.sromku.com/blog/datastore-sql-migration 6 | --- 7 | 8 | **Run it yourself** 9 | 10 | `go get -u github.com/sromku/datastore-to-sql/backup` 11 | 12 | **Load the backup file into model** 13 | 14 | This script will load the backup file into 'Profile' model and print it 15 | 16 | ``` go 17 | import ( 18 | "fmt" 19 | "github.com/sromku/datastore-to-sql/backup" 20 | ) 21 | 22 | func main() { 23 | backupPath := ".../output-0" 24 | backup.Load(backupPath, &Profile{}, nil, 25 | func(res interface{}) { 26 | profile, _ := res.(*Profile) // the loaded model 27 | fmt.Println(profile) 28 | }) 29 | } 30 | 31 | type Profile struct { 32 | Name string `datastore:"name, noindex"` 33 | Email string `datastore:"email"` 34 | Gender int `datastore:"gender, noindex"` 35 | } 36 | ``` -------------------------------------------------------------------------------- /backup/.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /backup/backup.go: -------------------------------------------------------------------------------- 1 | package backup 2 | 3 | import ( 4 | "github.com/golang/protobuf/proto" 5 | "github.com/syndtr/goleveldb/leveldb/journal" 6 | "io/ioutil" 7 | "log" 8 | "os" 9 | pb "github.com/sromku/datastore-to-sql/backup/pb" 10 | ) 11 | 12 | // Load the backup into real model 13 | // backupFilePath - the backup file path 14 | // dst - the struct model that represents datastore entity and the model you want to load the data of this backup 15 | // onPreload - callback that will be called before loading each entity 16 | // onResult - callback that will be called with already loaded entity in the model 17 | func Load(backupFilePath string, dst interface{}, onPreload func(dst interface{}), onResult func(dst interface{})) { 18 | f, err := os.Open(backupFilePath) 19 | if err != nil { 20 | log.Fatal(err) 21 | } 22 | defer f.Close() 23 | 24 | journals := journal.NewReader(f, nil, false, true) 25 | for { 26 | j, err := journals.Next() 27 | if err != nil { 28 | // log.Fatal(err) 29 | break 30 | } 31 | b, err := ioutil.ReadAll(j) 32 | if err != nil { 33 | // log.Fatal(err) 34 | break 35 | } 36 | pb := &pb.EntityProto{} 37 | if err := proto.Unmarshal(b, pb); err != nil { 38 | log.Fatal(err) 39 | break 40 | } 41 | if onPreload != nil { 42 | onPreload(dst) 43 | } 44 | LoadEntity(dst, pb) 45 | onResult(dst) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /backup/datastore.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | package backup 6 | 7 | import ( 8 | "errors" 9 | "fmt" 10 | "reflect" 11 | 12 | "github.com/golang/protobuf/proto" 13 | 14 | pb "github.com/sromku/datastore-to-sql/backup/pb" 15 | ) 16 | 17 | var ( 18 | // ErrInvalidEntityType is returned when functions like Get or Next are 19 | // passed a dst or src argument of invalid type. 20 | ErrInvalidEntityType = errors.New("datastore: invalid entity type") 21 | // ErrInvalidKey is returned when an invalid key is presented. 22 | ErrInvalidKey = errors.New("datastore: invalid key") 23 | // ErrNoSuchEntity is returned when no entity was found for a given key. 24 | ErrNoSuchEntity = errors.New("datastore: no such entity") 25 | ) 26 | 27 | // ErrFieldMismatch is returned when a field is to be loaded into a different 28 | // type than the one it was stored from, or when a field is missing or 29 | // unexported in the destination struct. 30 | // StructType is the type of the struct pointed to by the destination argument 31 | // passed to Get or to Iterator.Next. 32 | type ErrFieldMismatch struct { 33 | StructType reflect.Type 34 | FieldName string 35 | Reason string 36 | } 37 | 38 | func (e *ErrFieldMismatch) Error() string { 39 | return fmt.Sprintf("datastore: cannot load field %q into a %q: %s", 40 | e.FieldName, e.StructType, e.Reason) 41 | } 42 | 43 | // protoToKey converts a Reference proto to a *Key. 44 | func protoToKey(r *pb.Reference) (k *Key, err error) { 45 | appID := r.GetApp() 46 | namespace := r.GetNameSpace() 47 | for _, e := range r.Path.Element { 48 | k = &Key{ 49 | kind: e.GetType(), 50 | stringID: e.GetName(), 51 | intID: e.GetId(), 52 | parent: k, 53 | appID: appID, 54 | namespace: namespace, 55 | } 56 | if !k.valid() { 57 | return nil, ErrInvalidKey 58 | } 59 | } 60 | return 61 | } 62 | 63 | // keyToProto converts a *Key to a Reference proto. 64 | func keyToProto(defaultAppID string, k *Key) *pb.Reference { 65 | appID := k.appID 66 | if appID == "" { 67 | appID = defaultAppID 68 | } 69 | n := 0 70 | for i := k; i != nil; i = i.parent { 71 | n++ 72 | } 73 | e := make([]*pb.Path_Element, n) 74 | for i := k; i != nil; i = i.parent { 75 | n-- 76 | e[n] = &pb.Path_Element{ 77 | Type: &i.kind, 78 | } 79 | // At most one of {Name,Id} should be set. 80 | // Neither will be set for incomplete keys. 81 | if i.stringID != "" { 82 | e[n].Name = &i.stringID 83 | } else if i.intID != 0 { 84 | e[n].Id = &i.intID 85 | } 86 | } 87 | var namespace *string 88 | if k.namespace != "" { 89 | namespace = proto.String(k.namespace) 90 | } 91 | return &pb.Reference{ 92 | App: proto.String(appID), 93 | NameSpace: namespace, 94 | Path: &pb.Path{ 95 | Element: e, 96 | }, 97 | } 98 | } 99 | 100 | // It's unfortunate that the two semantically equivalent concepts pb.Reference 101 | // and pb.PropertyValue_ReferenceValue aren't the same type. For example, the 102 | // two have different protobuf field numbers. 103 | 104 | // referenceValueToKey is the same as protoToKey except the input is a 105 | // PropertyValue_ReferenceValue instead of a Reference. 106 | func referenceValueToKey(r *pb.PropertyValue_ReferenceValue) (k *Key, err error) { 107 | appID := r.GetApp() 108 | namespace := r.GetNameSpace() 109 | for _, e := range r.Pathelement { 110 | k = &Key{ 111 | kind: e.GetType(), 112 | stringID: e.GetName(), 113 | intID: e.GetId(), 114 | parent: k, 115 | appID: appID, 116 | namespace: namespace, 117 | } 118 | if !k.valid() { 119 | return nil, ErrInvalidKey 120 | } 121 | } 122 | return 123 | } 124 | 125 | // keyToReferenceValue is the same as keyToProto except the output is a 126 | // PropertyValue_ReferenceValue instead of a Reference. 127 | func keyToReferenceValue(defaultAppID string, k *Key) *pb.PropertyValue_ReferenceValue { 128 | ref := keyToProto(defaultAppID, k) 129 | pe := make([]*pb.PropertyValue_ReferenceValue_PathElement, len(ref.Path.Element)) 130 | for i, e := range ref.Path.Element { 131 | pe[i] = &pb.PropertyValue_ReferenceValue_PathElement{ 132 | Type: e.Type, 133 | Id: e.Id, 134 | Name: e.Name, 135 | } 136 | } 137 | return &pb.PropertyValue_ReferenceValue{ 138 | App: ref.App, 139 | NameSpace: ref.NameSpace, 140 | Pathelement: pe, 141 | } 142 | } 143 | 144 | type multiArgType int 145 | 146 | const ( 147 | multiArgTypeInvalid multiArgType = iota 148 | multiArgTypePropertyLoadSaver 149 | multiArgTypeStruct 150 | multiArgTypeStructPtr 151 | multiArgTypeInterface 152 | ) 153 | -------------------------------------------------------------------------------- /backup/key.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | package backup 6 | 7 | import ( 8 | "bytes" 9 | "encoding/base64" 10 | "encoding/gob" 11 | "errors" 12 | "strconv" 13 | "strings" 14 | 15 | "github.com/golang/protobuf/proto" 16 | 17 | pb "github.com/sromku/datastore-to-sql/backup/pb" 18 | ) 19 | 20 | // Key represents the datastore key for a stored entity, and is immutable. 21 | type Key struct { 22 | kind string 23 | stringID string 24 | intID int64 25 | parent *Key 26 | appID string 27 | namespace string 28 | } 29 | 30 | // Kind returns the key's kind (also known as entity type). 31 | func (k *Key) Kind() string { 32 | return k.kind 33 | } 34 | 35 | // StringID returns the key's string ID (also known as an entity name or key 36 | // name), which may be "". 37 | func (k *Key) StringID() string { 38 | return k.stringID 39 | } 40 | 41 | // IntID returns the key's integer ID, which may be 0. 42 | func (k *Key) IntID() int64 { 43 | return k.intID 44 | } 45 | 46 | // Parent returns the key's parent key, which may be nil. 47 | func (k *Key) Parent() *Key { 48 | return k.parent 49 | } 50 | 51 | // AppID returns the key's application ID. 52 | func (k *Key) AppID() string { 53 | return k.appID 54 | } 55 | 56 | // Namespace returns the key's namespace. 57 | func (k *Key) Namespace() string { 58 | return k.namespace 59 | } 60 | 61 | // Incomplete returns whether the key does not refer to a stored entity. 62 | // In particular, whether the key has a zero StringID and a zero IntID. 63 | func (k *Key) Incomplete() bool { 64 | return k.stringID == "" && k.intID == 0 65 | } 66 | 67 | // valid returns whether the key is valid. 68 | func (k *Key) valid() bool { 69 | if k == nil { 70 | return false 71 | } 72 | for ; k != nil; k = k.parent { 73 | if k.kind == "" || k.appID == "" { 74 | return false 75 | } 76 | if k.stringID != "" && k.intID != 0 { 77 | return false 78 | } 79 | if k.parent != nil { 80 | if k.parent.Incomplete() { 81 | return false 82 | } 83 | if k.parent.appID != k.appID || k.parent.namespace != k.namespace { 84 | return false 85 | } 86 | } 87 | } 88 | return true 89 | } 90 | 91 | // Equal returns whether two keys are equal. 92 | func (k *Key) Equal(o *Key) bool { 93 | for k != nil && o != nil { 94 | if k.kind != o.kind || k.stringID != o.stringID || k.intID != o.intID || k.appID != o.appID || k.namespace != o.namespace { 95 | return false 96 | } 97 | k, o = k.parent, o.parent 98 | } 99 | return k == o 100 | } 101 | 102 | // root returns the furthest ancestor of a key, which may be itself. 103 | func (k *Key) root() *Key { 104 | for k.parent != nil { 105 | k = k.parent 106 | } 107 | return k 108 | } 109 | 110 | // marshal marshals the key's string representation to the buffer. 111 | func (k *Key) marshal(b *bytes.Buffer) { 112 | if k.parent != nil { 113 | k.parent.marshal(b) 114 | } 115 | b.WriteByte('/') 116 | b.WriteString(k.kind) 117 | b.WriteByte(',') 118 | if k.stringID != "" { 119 | b.WriteString(k.stringID) 120 | } else { 121 | b.WriteString(strconv.FormatInt(k.intID, 10)) 122 | } 123 | } 124 | 125 | // String returns a string representation of the key. 126 | func (k *Key) String() string { 127 | if k == nil { 128 | return "" 129 | } 130 | b := bytes.NewBuffer(make([]byte, 0, 512)) 131 | k.marshal(b) 132 | return b.String() 133 | } 134 | 135 | type gobKey struct { 136 | Kind string 137 | StringID string 138 | IntID int64 139 | Parent *gobKey 140 | AppID string 141 | Namespace string 142 | } 143 | 144 | func keyToGobKey(k *Key) *gobKey { 145 | if k == nil { 146 | return nil 147 | } 148 | return &gobKey{ 149 | Kind: k.kind, 150 | StringID: k.stringID, 151 | IntID: k.intID, 152 | Parent: keyToGobKey(k.parent), 153 | AppID: k.appID, 154 | Namespace: k.namespace, 155 | } 156 | } 157 | 158 | func gobKeyToKey(gk *gobKey) *Key { 159 | if gk == nil { 160 | return nil 161 | } 162 | return &Key{ 163 | kind: gk.Kind, 164 | stringID: gk.StringID, 165 | intID: gk.IntID, 166 | parent: gobKeyToKey(gk.Parent), 167 | appID: gk.AppID, 168 | namespace: gk.Namespace, 169 | } 170 | } 171 | 172 | func (k *Key) GobEncode() ([]byte, error) { 173 | buf := new(bytes.Buffer) 174 | if err := gob.NewEncoder(buf).Encode(keyToGobKey(k)); err != nil { 175 | return nil, err 176 | } 177 | return buf.Bytes(), nil 178 | } 179 | 180 | func (k *Key) GobDecode(buf []byte) error { 181 | gk := new(gobKey) 182 | if err := gob.NewDecoder(bytes.NewBuffer(buf)).Decode(gk); err != nil { 183 | return err 184 | } 185 | *k = *gobKeyToKey(gk) 186 | return nil 187 | } 188 | 189 | func (k *Key) MarshalJSON() ([]byte, error) { 190 | return []byte(`"` + k.Encode() + `"`), nil 191 | } 192 | 193 | func (k *Key) UnmarshalJSON(buf []byte) error { 194 | if len(buf) < 2 || buf[0] != '"' || buf[len(buf)-1] != '"' { 195 | return errors.New("datastore: bad JSON key") 196 | } 197 | k2, err := DecodeKey(string(buf[1 : len(buf)-1])) 198 | if err != nil { 199 | return err 200 | } 201 | *k = *k2 202 | return nil 203 | } 204 | 205 | // Encode returns an opaque representation of the key 206 | // suitable for use in HTML and URLs. 207 | // This is compatible with the Python and Java runtimes. 208 | func (k *Key) Encode() string { 209 | ref := keyToProto("", k) 210 | 211 | b, err := proto.Marshal(ref) 212 | if err != nil { 213 | panic(err) 214 | } 215 | 216 | // Trailing padding is stripped. 217 | return strings.TrimRight(base64.URLEncoding.EncodeToString(b), "=") 218 | } 219 | 220 | // DecodeKey decodes a key from the opaque representation returned by Encode. 221 | func DecodeKey(encoded string) (*Key, error) { 222 | // Re-add padding. 223 | if m := len(encoded) % 4; m != 0 { 224 | encoded += strings.Repeat("=", 4-m) 225 | } 226 | 227 | b, err := base64.URLEncoding.DecodeString(encoded) 228 | if err != nil { 229 | return nil, err 230 | } 231 | 232 | ref := new(pb.Reference) 233 | if err := proto.Unmarshal(b, ref); err != nil { 234 | return nil, err 235 | } 236 | 237 | return protoToKey(ref) 238 | } 239 | -------------------------------------------------------------------------------- /backup/load.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | package backup 6 | 7 | import ( 8 | "fmt" 9 | "reflect" 10 | "time" 11 | 12 | "google.golang.org/appengine" 13 | pb "github.com/sromku/datastore-to-sql/backup/pb" 14 | ) 15 | 16 | var ( 17 | typeOfBlobKey = reflect.TypeOf(appengine.BlobKey("")) 18 | typeOfByteSlice = reflect.TypeOf([]byte(nil)) 19 | typeOfByteString = reflect.TypeOf(ByteString(nil)) 20 | typeOfGeoPoint = reflect.TypeOf(appengine.GeoPoint{}) 21 | typeOfTime = reflect.TypeOf(time.Time{}) 22 | ) 23 | 24 | // typeMismatchReason returns a string explaining why the property p could not 25 | // be stored in an entity field of type v.Type(). 26 | func typeMismatchReason(p Property, v reflect.Value) string { 27 | entityType := "empty" 28 | switch p.Value.(type) { 29 | case int64: 30 | entityType = "int" 31 | case bool: 32 | entityType = "bool" 33 | case string: 34 | entityType = "string" 35 | case float64: 36 | entityType = "float" 37 | case *Key: 38 | entityType = "*datastore.Key" 39 | case time.Time: 40 | entityType = "time.Time" 41 | case appengine.BlobKey: 42 | entityType = "appengine.BlobKey" 43 | case appengine.GeoPoint: 44 | entityType = "appengine.GeoPoint" 45 | case ByteString: 46 | entityType = "datastore.ByteString" 47 | case []byte: 48 | entityType = "[]byte" 49 | } 50 | return fmt.Sprintf("type mismatch: %s versus %v", entityType, v.Type()) 51 | } 52 | 53 | type propertyLoader struct { 54 | // m holds the number of times a substruct field like "Foo.Bar.Baz" has 55 | // been seen so far. The map is constructed lazily. 56 | m map[string]int 57 | } 58 | 59 | func (l *propertyLoader) load(codec *structCodec, structValue reflect.Value, p Property, requireSlice bool) string { 60 | var v reflect.Value 61 | // Traverse a struct's struct-typed fields. 62 | for name := p.Name; ; { 63 | decoder, ok := codec.byName[name] 64 | if !ok { 65 | return "no such struct field" 66 | } 67 | v = structValue.Field(decoder.index) 68 | if !v.IsValid() { 69 | return "no such struct field" 70 | } 71 | if !v.CanSet() { 72 | return "cannot set struct field" 73 | } 74 | 75 | if decoder.substructCodec == nil { 76 | break 77 | } 78 | 79 | if v.Kind() == reflect.Slice { 80 | if l.m == nil { 81 | l.m = make(map[string]int) 82 | } 83 | index := l.m[p.Name] 84 | l.m[p.Name] = index + 1 85 | for v.Len() <= index { 86 | v.Set(reflect.Append(v, reflect.New(v.Type().Elem()).Elem())) 87 | } 88 | structValue = v.Index(index) 89 | requireSlice = false 90 | } else { 91 | structValue = v 92 | } 93 | // Strip the "I." from "I.X". 94 | name = name[len(codec.byIndex[decoder.index].name):] 95 | codec = decoder.substructCodec 96 | } 97 | 98 | var slice reflect.Value 99 | if v.Kind() == reflect.Slice && v.Type().Elem().Kind() != reflect.Uint8 { 100 | slice = v 101 | v = reflect.New(v.Type().Elem()).Elem() 102 | } else if requireSlice { 103 | return "multiple-valued property requires a slice field type" 104 | } 105 | 106 | // Convert indexValues to a Go value with a meaning derived from the 107 | // destination type. 108 | pValue := p.Value 109 | if iv, ok := pValue.(indexValue); ok { 110 | meaning := pb.Property_NO_MEANING 111 | switch v.Type() { 112 | case typeOfBlobKey: 113 | meaning = pb.Property_BLOBKEY 114 | case typeOfByteSlice: 115 | meaning = pb.Property_BLOB 116 | case typeOfByteString: 117 | meaning = pb.Property_BYTESTRING 118 | case typeOfGeoPoint: 119 | meaning = pb.Property_GEORSS_POINT 120 | case typeOfTime: 121 | meaning = pb.Property_GD_WHEN 122 | } 123 | var err error 124 | pValue, err = propValue(iv.value, meaning) 125 | if err != nil { 126 | return err.Error() 127 | } 128 | } 129 | 130 | switch v.Kind() { 131 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 132 | x, ok := pValue.(int64) 133 | if !ok && pValue != nil { 134 | return typeMismatchReason(p, v) 135 | } 136 | if v.OverflowInt(x) { 137 | return fmt.Sprintf("value %v overflows struct field of type %v", x, v.Type()) 138 | } 139 | v.SetInt(x) 140 | case reflect.Bool: 141 | x, ok := pValue.(bool) 142 | if !ok && pValue != nil { 143 | return typeMismatchReason(p, v) 144 | } 145 | v.SetBool(x) 146 | case reflect.String: 147 | switch x := pValue.(type) { 148 | case appengine.BlobKey: 149 | v.SetString(string(x)) 150 | case ByteString: 151 | v.SetString(string(x)) 152 | case string: 153 | v.SetString(x) 154 | default: 155 | if pValue != nil { 156 | return typeMismatchReason(p, v) 157 | } 158 | } 159 | case reflect.Float32, reflect.Float64: 160 | x, ok := pValue.(float64) 161 | if !ok && pValue != nil { 162 | return typeMismatchReason(p, v) 163 | } 164 | if v.OverflowFloat(x) { 165 | return fmt.Sprintf("value %v overflows struct field of type %v", x, v.Type()) 166 | } 167 | v.SetFloat(x) 168 | case reflect.Ptr: 169 | x, ok := pValue.(*Key) 170 | if !ok && pValue != nil { 171 | return typeMismatchReason(p, v) 172 | } 173 | if _, ok := v.Interface().(*Key); !ok { 174 | return typeMismatchReason(p, v) 175 | } 176 | v.Set(reflect.ValueOf(x)) 177 | case reflect.Struct: 178 | switch v.Type() { 179 | case typeOfTime: 180 | x, ok := pValue.(time.Time) 181 | if !ok && pValue != nil { 182 | return typeMismatchReason(p, v) 183 | } 184 | v.Set(reflect.ValueOf(x)) 185 | case typeOfGeoPoint: 186 | x, ok := pValue.(appengine.GeoPoint) 187 | if !ok && pValue != nil { 188 | return typeMismatchReason(p, v) 189 | } 190 | v.Set(reflect.ValueOf(x)) 191 | default: 192 | return typeMismatchReason(p, v) 193 | } 194 | case reflect.Slice: 195 | x, ok := pValue.([]byte) 196 | if !ok { 197 | if y, yok := pValue.(ByteString); yok { 198 | x, ok = []byte(y), true 199 | } 200 | } 201 | if !ok && pValue != nil { 202 | return typeMismatchReason(p, v) 203 | } 204 | if v.Type().Elem().Kind() != reflect.Uint8 { 205 | return typeMismatchReason(p, v) 206 | } 207 | v.SetBytes(x) 208 | default: 209 | return typeMismatchReason(p, v) 210 | } 211 | if slice.IsValid() { 212 | slice.Set(reflect.Append(slice, v)) 213 | } 214 | return "" 215 | } 216 | 217 | // loadEntity loads an EntityProto into PropertyLoadSaver or struct pointer. 218 | func LoadEntity(dst interface{}, src *pb.EntityProto) (err error) { 219 | props, err := protoToProperties(src) 220 | if err != nil { 221 | return err 222 | } 223 | if e, ok := dst.(PropertyLoadSaver); ok { 224 | return e.Load(props) 225 | } 226 | return LoadStruct(dst, props) 227 | } 228 | 229 | func (s structPLS) Load(props []Property) error { 230 | var fieldName, reason string 231 | var l propertyLoader 232 | for _, p := range props { 233 | if errStr := l.load(s.codec, s.v, p, p.Multiple); errStr != "" { 234 | // We don't return early, as we try to load as many properties as possible. 235 | // It is valid to load an entity into a struct that cannot fully represent it. 236 | // That case returns an error, but the caller is free to ignore it. 237 | fieldName, reason = p.Name, errStr 238 | } 239 | } 240 | if reason != "" { 241 | return &ErrFieldMismatch{ 242 | StructType: s.v.Type(), 243 | FieldName: fieldName, 244 | Reason: reason, 245 | } 246 | } 247 | return nil 248 | } 249 | 250 | func protoToProperties(src *pb.EntityProto) ([]Property, error) { 251 | props, rawProps := src.Property, src.RawProperty 252 | out := make([]Property, 0, len(props)+len(rawProps)) 253 | for { 254 | var ( 255 | x *pb.Property 256 | noIndex bool 257 | ) 258 | if len(props) > 0 { 259 | x, props = props[0], props[1:] 260 | } else if len(rawProps) > 0 { 261 | x, rawProps = rawProps[0], rawProps[1:] 262 | noIndex = true 263 | } else { 264 | break 265 | } 266 | 267 | var value interface{} 268 | if x.Meaning != nil && *x.Meaning == pb.Property_INDEX_VALUE { 269 | value = indexValue{x.Value} 270 | } else { 271 | var err error 272 | value, err = propValue(x.Value, x.GetMeaning()) 273 | if err != nil { 274 | return nil, err 275 | } 276 | } 277 | out = append(out, Property{ 278 | Name: x.GetName(), 279 | Value: value, 280 | NoIndex: noIndex, 281 | Multiple: x.GetMultiple(), 282 | }) 283 | } 284 | return out, nil 285 | } 286 | 287 | // propValue returns a Go value that combines the raw PropertyValue with a 288 | // meaning. For example, an Int64Value with GD_WHEN becomes a time.Time. 289 | func propValue(v *pb.PropertyValue, m pb.Property_Meaning) (interface{}, error) { 290 | switch { 291 | case v.Int64Value != nil: 292 | if m == pb.Property_GD_WHEN { 293 | return fromUnixMicro(*v.Int64Value), nil 294 | } else { 295 | return *v.Int64Value, nil 296 | } 297 | case v.BooleanValue != nil: 298 | return *v.BooleanValue, nil 299 | case v.StringValue != nil: 300 | if m == pb.Property_BLOB { 301 | return []byte(*v.StringValue), nil 302 | } else if m == pb.Property_BLOBKEY { 303 | return appengine.BlobKey(*v.StringValue), nil 304 | } else if m == pb.Property_BYTESTRING { 305 | return ByteString(*v.StringValue), nil 306 | } else { 307 | return *v.StringValue, nil 308 | } 309 | case v.DoubleValue != nil: 310 | return *v.DoubleValue, nil 311 | case v.Referencevalue != nil: 312 | key, err := referenceValueToKey(v.Referencevalue) 313 | if err != nil { 314 | return nil, err 315 | } 316 | return key, nil 317 | case v.Pointvalue != nil: 318 | // NOTE: Strangely, latitude maps to X, longitude to Y. 319 | return appengine.GeoPoint{Lat: v.Pointvalue.GetX(), Lng: v.Pointvalue.GetY()}, nil 320 | } 321 | return nil, nil 322 | } 323 | 324 | // indexValue is a Property value that is created when entities are loaded from 325 | // an index, such as from a projection query. 326 | // 327 | // Such Property values do not contain all of the metadata required to be 328 | // faithfully represented as a Go value, and are instead represented as an 329 | // opaque indexValue. Load the properties into a concrete struct type (e.g. by 330 | // passing a struct pointer to Iterator.Next) to reconstruct actual Go values 331 | // of type int, string, time.Time, etc. 332 | type indexValue struct { 333 | value *pb.PropertyValue 334 | } 335 | -------------------------------------------------------------------------------- /backup/metadata.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | package backup 6 | 7 | 8 | // Datastore kinds for the metadata entities. 9 | const ( 10 | namespaceKind = "__namespace__" 11 | kindKind = "__kind__" 12 | propertyKind = "__property__" 13 | entityGroupKind = "__entitygroup__" 14 | ) 15 | -------------------------------------------------------------------------------- /backup/pb/datastore_v3.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: google.golang.org/appengine/internal/datastore/datastore_v3.proto 3 | // DO NOT EDIT! 4 | 5 | /* 6 | Package datastore is a generated protocol buffer package. 7 | 8 | It is generated from these files: 9 | google.golang.org/appengine/internal/datastore/datastore_v3.proto 10 | 11 | It has these top-level messages: 12 | Action 13 | PropertyValue 14 | Property 15 | Path 16 | Reference 17 | User 18 | EntityProto 19 | CompositeProperty 20 | Index 21 | CompositeIndex 22 | IndexPostfix 23 | IndexPosition 24 | Snapshot 25 | InternalHeader 26 | Transaction 27 | Query 28 | CompiledQuery 29 | CompiledCursor 30 | Cursor 31 | Error 32 | Cost 33 | GetRequest 34 | GetResponse 35 | PutRequest 36 | PutResponse 37 | TouchRequest 38 | TouchResponse 39 | DeleteRequest 40 | DeleteResponse 41 | NextRequest 42 | QueryResult 43 | AllocateIdsRequest 44 | AllocateIdsResponse 45 | CompositeIndices 46 | AddActionsRequest 47 | AddActionsResponse 48 | BeginTransactionRequest 49 | CommitResponse 50 | */ 51 | package pb 52 | 53 | import proto "github.com/golang/protobuf/proto" 54 | import fmt "fmt" 55 | import math "math" 56 | 57 | // Reference imports to suppress errors if they are not otherwise used. 58 | var _ = proto.Marshal 59 | var _ = fmt.Errorf 60 | var _ = math.Inf 61 | 62 | type Property_Meaning int32 63 | 64 | const ( 65 | Property_NO_MEANING Property_Meaning = 0 66 | Property_BLOB Property_Meaning = 14 67 | Property_TEXT Property_Meaning = 15 68 | Property_BYTESTRING Property_Meaning = 16 69 | Property_ATOM_CATEGORY Property_Meaning = 1 70 | Property_ATOM_LINK Property_Meaning = 2 71 | Property_ATOM_TITLE Property_Meaning = 3 72 | Property_ATOM_CONTENT Property_Meaning = 4 73 | Property_ATOM_SUMMARY Property_Meaning = 5 74 | Property_ATOM_AUTHOR Property_Meaning = 6 75 | Property_GD_WHEN Property_Meaning = 7 76 | Property_GD_EMAIL Property_Meaning = 8 77 | Property_GEORSS_POINT Property_Meaning = 9 78 | Property_GD_IM Property_Meaning = 10 79 | Property_GD_PHONENUMBER Property_Meaning = 11 80 | Property_GD_POSTALADDRESS Property_Meaning = 12 81 | Property_GD_RATING Property_Meaning = 13 82 | Property_BLOBKEY Property_Meaning = 17 83 | Property_ENTITY_PROTO Property_Meaning = 19 84 | Property_INDEX_VALUE Property_Meaning = 18 85 | ) 86 | 87 | var Property_Meaning_name = map[int32]string{ 88 | 0: "NO_MEANING", 89 | 14: "BLOB", 90 | 15: "TEXT", 91 | 16: "BYTESTRING", 92 | 1: "ATOM_CATEGORY", 93 | 2: "ATOM_LINK", 94 | 3: "ATOM_TITLE", 95 | 4: "ATOM_CONTENT", 96 | 5: "ATOM_SUMMARY", 97 | 6: "ATOM_AUTHOR", 98 | 7: "GD_WHEN", 99 | 8: "GD_EMAIL", 100 | 9: "GEORSS_POINT", 101 | 10: "GD_IM", 102 | 11: "GD_PHONENUMBER", 103 | 12: "GD_POSTALADDRESS", 104 | 13: "GD_RATING", 105 | 17: "BLOBKEY", 106 | 19: "ENTITY_PROTO", 107 | 18: "INDEX_VALUE", 108 | } 109 | var Property_Meaning_value = map[string]int32{ 110 | "NO_MEANING": 0, 111 | "BLOB": 14, 112 | "TEXT": 15, 113 | "BYTESTRING": 16, 114 | "ATOM_CATEGORY": 1, 115 | "ATOM_LINK": 2, 116 | "ATOM_TITLE": 3, 117 | "ATOM_CONTENT": 4, 118 | "ATOM_SUMMARY": 5, 119 | "ATOM_AUTHOR": 6, 120 | "GD_WHEN": 7, 121 | "GD_EMAIL": 8, 122 | "GEORSS_POINT": 9, 123 | "GD_IM": 10, 124 | "GD_PHONENUMBER": 11, 125 | "GD_POSTALADDRESS": 12, 126 | "GD_RATING": 13, 127 | "BLOBKEY": 17, 128 | "ENTITY_PROTO": 19, 129 | "INDEX_VALUE": 18, 130 | } 131 | 132 | func (x Property_Meaning) Enum() *Property_Meaning { 133 | p := new(Property_Meaning) 134 | *p = x 135 | return p 136 | } 137 | func (x Property_Meaning) String() string { 138 | return proto.EnumName(Property_Meaning_name, int32(x)) 139 | } 140 | func (x *Property_Meaning) UnmarshalJSON(data []byte) error { 141 | value, err := proto.UnmarshalJSONEnum(Property_Meaning_value, data, "Property_Meaning") 142 | if err != nil { 143 | return err 144 | } 145 | *x = Property_Meaning(value) 146 | return nil 147 | } 148 | 149 | type Property_FtsTokenizationOption int32 150 | 151 | const ( 152 | Property_HTML Property_FtsTokenizationOption = 1 153 | Property_ATOM Property_FtsTokenizationOption = 2 154 | ) 155 | 156 | var Property_FtsTokenizationOption_name = map[int32]string{ 157 | 1: "HTML", 158 | 2: "ATOM", 159 | } 160 | var Property_FtsTokenizationOption_value = map[string]int32{ 161 | "HTML": 1, 162 | "ATOM": 2, 163 | } 164 | 165 | func (x Property_FtsTokenizationOption) Enum() *Property_FtsTokenizationOption { 166 | p := new(Property_FtsTokenizationOption) 167 | *p = x 168 | return p 169 | } 170 | func (x Property_FtsTokenizationOption) String() string { 171 | return proto.EnumName(Property_FtsTokenizationOption_name, int32(x)) 172 | } 173 | func (x *Property_FtsTokenizationOption) UnmarshalJSON(data []byte) error { 174 | value, err := proto.UnmarshalJSONEnum(Property_FtsTokenizationOption_value, data, "Property_FtsTokenizationOption") 175 | if err != nil { 176 | return err 177 | } 178 | *x = Property_FtsTokenizationOption(value) 179 | return nil 180 | } 181 | 182 | type EntityProto_Kind int32 183 | 184 | const ( 185 | EntityProto_GD_CONTACT EntityProto_Kind = 1 186 | EntityProto_GD_EVENT EntityProto_Kind = 2 187 | EntityProto_GD_MESSAGE EntityProto_Kind = 3 188 | ) 189 | 190 | var EntityProto_Kind_name = map[int32]string{ 191 | 1: "GD_CONTACT", 192 | 2: "GD_EVENT", 193 | 3: "GD_MESSAGE", 194 | } 195 | var EntityProto_Kind_value = map[string]int32{ 196 | "GD_CONTACT": 1, 197 | "GD_EVENT": 2, 198 | "GD_MESSAGE": 3, 199 | } 200 | 201 | func (x EntityProto_Kind) Enum() *EntityProto_Kind { 202 | p := new(EntityProto_Kind) 203 | *p = x 204 | return p 205 | } 206 | func (x EntityProto_Kind) String() string { 207 | return proto.EnumName(EntityProto_Kind_name, int32(x)) 208 | } 209 | func (x *EntityProto_Kind) UnmarshalJSON(data []byte) error { 210 | value, err := proto.UnmarshalJSONEnum(EntityProto_Kind_value, data, "EntityProto_Kind") 211 | if err != nil { 212 | return err 213 | } 214 | *x = EntityProto_Kind(value) 215 | return nil 216 | } 217 | 218 | type Index_Property_Direction int32 219 | 220 | const ( 221 | Index_Property_ASCENDING Index_Property_Direction = 1 222 | Index_Property_DESCENDING Index_Property_Direction = 2 223 | ) 224 | 225 | var Index_Property_Direction_name = map[int32]string{ 226 | 1: "ASCENDING", 227 | 2: "DESCENDING", 228 | } 229 | var Index_Property_Direction_value = map[string]int32{ 230 | "ASCENDING": 1, 231 | "DESCENDING": 2, 232 | } 233 | 234 | func (x Index_Property_Direction) Enum() *Index_Property_Direction { 235 | p := new(Index_Property_Direction) 236 | *p = x 237 | return p 238 | } 239 | func (x Index_Property_Direction) String() string { 240 | return proto.EnumName(Index_Property_Direction_name, int32(x)) 241 | } 242 | func (x *Index_Property_Direction) UnmarshalJSON(data []byte) error { 243 | value, err := proto.UnmarshalJSONEnum(Index_Property_Direction_value, data, "Index_Property_Direction") 244 | if err != nil { 245 | return err 246 | } 247 | *x = Index_Property_Direction(value) 248 | return nil 249 | } 250 | 251 | type CompositeIndex_State int32 252 | 253 | const ( 254 | CompositeIndex_WRITE_ONLY CompositeIndex_State = 1 255 | CompositeIndex_READ_WRITE CompositeIndex_State = 2 256 | CompositeIndex_DELETED CompositeIndex_State = 3 257 | CompositeIndex_ERROR CompositeIndex_State = 4 258 | ) 259 | 260 | var CompositeIndex_State_name = map[int32]string{ 261 | 1: "WRITE_ONLY", 262 | 2: "READ_WRITE", 263 | 3: "DELETED", 264 | 4: "ERROR", 265 | } 266 | var CompositeIndex_State_value = map[string]int32{ 267 | "WRITE_ONLY": 1, 268 | "READ_WRITE": 2, 269 | "DELETED": 3, 270 | "ERROR": 4, 271 | } 272 | 273 | func (x CompositeIndex_State) Enum() *CompositeIndex_State { 274 | p := new(CompositeIndex_State) 275 | *p = x 276 | return p 277 | } 278 | func (x CompositeIndex_State) String() string { 279 | return proto.EnumName(CompositeIndex_State_name, int32(x)) 280 | } 281 | func (x *CompositeIndex_State) UnmarshalJSON(data []byte) error { 282 | value, err := proto.UnmarshalJSONEnum(CompositeIndex_State_value, data, "CompositeIndex_State") 283 | if err != nil { 284 | return err 285 | } 286 | *x = CompositeIndex_State(value) 287 | return nil 288 | } 289 | 290 | type Snapshot_Status int32 291 | 292 | const ( 293 | Snapshot_INACTIVE Snapshot_Status = 0 294 | Snapshot_ACTIVE Snapshot_Status = 1 295 | ) 296 | 297 | var Snapshot_Status_name = map[int32]string{ 298 | 0: "INACTIVE", 299 | 1: "ACTIVE", 300 | } 301 | var Snapshot_Status_value = map[string]int32{ 302 | "INACTIVE": 0, 303 | "ACTIVE": 1, 304 | } 305 | 306 | func (x Snapshot_Status) Enum() *Snapshot_Status { 307 | p := new(Snapshot_Status) 308 | *p = x 309 | return p 310 | } 311 | func (x Snapshot_Status) String() string { 312 | return proto.EnumName(Snapshot_Status_name, int32(x)) 313 | } 314 | func (x *Snapshot_Status) UnmarshalJSON(data []byte) error { 315 | value, err := proto.UnmarshalJSONEnum(Snapshot_Status_value, data, "Snapshot_Status") 316 | if err != nil { 317 | return err 318 | } 319 | *x = Snapshot_Status(value) 320 | return nil 321 | } 322 | 323 | type Query_Hint int32 324 | 325 | const ( 326 | Query_ORDER_FIRST Query_Hint = 1 327 | Query_ANCESTOR_FIRST Query_Hint = 2 328 | Query_FILTER_FIRST Query_Hint = 3 329 | ) 330 | 331 | var Query_Hint_name = map[int32]string{ 332 | 1: "ORDER_FIRST", 333 | 2: "ANCESTOR_FIRST", 334 | 3: "FILTER_FIRST", 335 | } 336 | var Query_Hint_value = map[string]int32{ 337 | "ORDER_FIRST": 1, 338 | "ANCESTOR_FIRST": 2, 339 | "FILTER_FIRST": 3, 340 | } 341 | 342 | func (x Query_Hint) Enum() *Query_Hint { 343 | p := new(Query_Hint) 344 | *p = x 345 | return p 346 | } 347 | func (x Query_Hint) String() string { 348 | return proto.EnumName(Query_Hint_name, int32(x)) 349 | } 350 | func (x *Query_Hint) UnmarshalJSON(data []byte) error { 351 | value, err := proto.UnmarshalJSONEnum(Query_Hint_value, data, "Query_Hint") 352 | if err != nil { 353 | return err 354 | } 355 | *x = Query_Hint(value) 356 | return nil 357 | } 358 | 359 | type Query_Filter_Operator int32 360 | 361 | const ( 362 | Query_Filter_LESS_THAN Query_Filter_Operator = 1 363 | Query_Filter_LESS_THAN_OR_EQUAL Query_Filter_Operator = 2 364 | Query_Filter_GREATER_THAN Query_Filter_Operator = 3 365 | Query_Filter_GREATER_THAN_OR_EQUAL Query_Filter_Operator = 4 366 | Query_Filter_EQUAL Query_Filter_Operator = 5 367 | Query_Filter_IN Query_Filter_Operator = 6 368 | Query_Filter_EXISTS Query_Filter_Operator = 7 369 | ) 370 | 371 | var Query_Filter_Operator_name = map[int32]string{ 372 | 1: "LESS_THAN", 373 | 2: "LESS_THAN_OR_EQUAL", 374 | 3: "GREATER_THAN", 375 | 4: "GREATER_THAN_OR_EQUAL", 376 | 5: "EQUAL", 377 | 6: "IN", 378 | 7: "EXISTS", 379 | } 380 | var Query_Filter_Operator_value = map[string]int32{ 381 | "LESS_THAN": 1, 382 | "LESS_THAN_OR_EQUAL": 2, 383 | "GREATER_THAN": 3, 384 | "GREATER_THAN_OR_EQUAL": 4, 385 | "EQUAL": 5, 386 | "IN": 6, 387 | "EXISTS": 7, 388 | } 389 | 390 | func (x Query_Filter_Operator) Enum() *Query_Filter_Operator { 391 | p := new(Query_Filter_Operator) 392 | *p = x 393 | return p 394 | } 395 | func (x Query_Filter_Operator) String() string { 396 | return proto.EnumName(Query_Filter_Operator_name, int32(x)) 397 | } 398 | func (x *Query_Filter_Operator) UnmarshalJSON(data []byte) error { 399 | value, err := proto.UnmarshalJSONEnum(Query_Filter_Operator_value, data, "Query_Filter_Operator") 400 | if err != nil { 401 | return err 402 | } 403 | *x = Query_Filter_Operator(value) 404 | return nil 405 | } 406 | 407 | type Query_Order_Direction int32 408 | 409 | const ( 410 | Query_Order_ASCENDING Query_Order_Direction = 1 411 | Query_Order_DESCENDING Query_Order_Direction = 2 412 | ) 413 | 414 | var Query_Order_Direction_name = map[int32]string{ 415 | 1: "ASCENDING", 416 | 2: "DESCENDING", 417 | } 418 | var Query_Order_Direction_value = map[string]int32{ 419 | "ASCENDING": 1, 420 | "DESCENDING": 2, 421 | } 422 | 423 | func (x Query_Order_Direction) Enum() *Query_Order_Direction { 424 | p := new(Query_Order_Direction) 425 | *p = x 426 | return p 427 | } 428 | func (x Query_Order_Direction) String() string { 429 | return proto.EnumName(Query_Order_Direction_name, int32(x)) 430 | } 431 | func (x *Query_Order_Direction) UnmarshalJSON(data []byte) error { 432 | value, err := proto.UnmarshalJSONEnum(Query_Order_Direction_value, data, "Query_Order_Direction") 433 | if err != nil { 434 | return err 435 | } 436 | *x = Query_Order_Direction(value) 437 | return nil 438 | } 439 | 440 | type Error_ErrorCode int32 441 | 442 | const ( 443 | Error_BAD_REQUEST Error_ErrorCode = 1 444 | Error_CONCURRENT_TRANSACTION Error_ErrorCode = 2 445 | Error_INTERNAL_ERROR Error_ErrorCode = 3 446 | Error_NEED_INDEX Error_ErrorCode = 4 447 | Error_TIMEOUT Error_ErrorCode = 5 448 | Error_PERMISSION_DENIED Error_ErrorCode = 6 449 | Error_BIGTABLE_ERROR Error_ErrorCode = 7 450 | Error_COMMITTED_BUT_STILL_APPLYING Error_ErrorCode = 8 451 | Error_CAPABILITY_DISABLED Error_ErrorCode = 9 452 | Error_TRY_ALTERNATE_BACKEND Error_ErrorCode = 10 453 | Error_SAFE_TIME_TOO_OLD Error_ErrorCode = 11 454 | ) 455 | 456 | var Error_ErrorCode_name = map[int32]string{ 457 | 1: "BAD_REQUEST", 458 | 2: "CONCURRENT_TRANSACTION", 459 | 3: "INTERNAL_ERROR", 460 | 4: "NEED_INDEX", 461 | 5: "TIMEOUT", 462 | 6: "PERMISSION_DENIED", 463 | 7: "BIGTABLE_ERROR", 464 | 8: "COMMITTED_BUT_STILL_APPLYING", 465 | 9: "CAPABILITY_DISABLED", 466 | 10: "TRY_ALTERNATE_BACKEND", 467 | 11: "SAFE_TIME_TOO_OLD", 468 | } 469 | var Error_ErrorCode_value = map[string]int32{ 470 | "BAD_REQUEST": 1, 471 | "CONCURRENT_TRANSACTION": 2, 472 | "INTERNAL_ERROR": 3, 473 | "NEED_INDEX": 4, 474 | "TIMEOUT": 5, 475 | "PERMISSION_DENIED": 6, 476 | "BIGTABLE_ERROR": 7, 477 | "COMMITTED_BUT_STILL_APPLYING": 8, 478 | "CAPABILITY_DISABLED": 9, 479 | "TRY_ALTERNATE_BACKEND": 10, 480 | "SAFE_TIME_TOO_OLD": 11, 481 | } 482 | 483 | func (x Error_ErrorCode) Enum() *Error_ErrorCode { 484 | p := new(Error_ErrorCode) 485 | *p = x 486 | return p 487 | } 488 | func (x Error_ErrorCode) String() string { 489 | return proto.EnumName(Error_ErrorCode_name, int32(x)) 490 | } 491 | func (x *Error_ErrorCode) UnmarshalJSON(data []byte) error { 492 | value, err := proto.UnmarshalJSONEnum(Error_ErrorCode_value, data, "Error_ErrorCode") 493 | if err != nil { 494 | return err 495 | } 496 | *x = Error_ErrorCode(value) 497 | return nil 498 | } 499 | 500 | type PutRequest_AutoIdPolicy int32 501 | 502 | const ( 503 | PutRequest_CURRENT PutRequest_AutoIdPolicy = 0 504 | PutRequest_SEQUENTIAL PutRequest_AutoIdPolicy = 1 505 | ) 506 | 507 | var PutRequest_AutoIdPolicy_name = map[int32]string{ 508 | 0: "CURRENT", 509 | 1: "SEQUENTIAL", 510 | } 511 | var PutRequest_AutoIdPolicy_value = map[string]int32{ 512 | "CURRENT": 0, 513 | "SEQUENTIAL": 1, 514 | } 515 | 516 | func (x PutRequest_AutoIdPolicy) Enum() *PutRequest_AutoIdPolicy { 517 | p := new(PutRequest_AutoIdPolicy) 518 | *p = x 519 | return p 520 | } 521 | func (x PutRequest_AutoIdPolicy) String() string { 522 | return proto.EnumName(PutRequest_AutoIdPolicy_name, int32(x)) 523 | } 524 | func (x *PutRequest_AutoIdPolicy) UnmarshalJSON(data []byte) error { 525 | value, err := proto.UnmarshalJSONEnum(PutRequest_AutoIdPolicy_value, data, "PutRequest_AutoIdPolicy") 526 | if err != nil { 527 | return err 528 | } 529 | *x = PutRequest_AutoIdPolicy(value) 530 | return nil 531 | } 532 | 533 | type Action struct { 534 | XXX_unrecognized []byte `json:"-"` 535 | } 536 | 537 | func (m *Action) Reset() { *m = Action{} } 538 | func (m *Action) String() string { return proto.CompactTextString(m) } 539 | func (*Action) ProtoMessage() {} 540 | 541 | type PropertyValue struct { 542 | Int64Value *int64 `protobuf:"varint,1,opt,name=int64Value" json:"int64Value,omitempty"` 543 | BooleanValue *bool `protobuf:"varint,2,opt,name=booleanValue" json:"booleanValue,omitempty"` 544 | StringValue *string `protobuf:"bytes,3,opt,name=stringValue" json:"stringValue,omitempty"` 545 | DoubleValue *float64 `protobuf:"fixed64,4,opt,name=doubleValue" json:"doubleValue,omitempty"` 546 | Pointvalue *PropertyValue_PointValue `protobuf:"group,5,opt,name=PointValue" json:"pointvalue,omitempty"` 547 | Uservalue *PropertyValue_UserValue `protobuf:"group,8,opt,name=UserValue" json:"uservalue,omitempty"` 548 | Referencevalue *PropertyValue_ReferenceValue `protobuf:"group,12,opt,name=ReferenceValue" json:"referencevalue,omitempty"` 549 | XXX_unrecognized []byte `json:"-"` 550 | } 551 | 552 | func (m *PropertyValue) Reset() { *m = PropertyValue{} } 553 | func (m *PropertyValue) String() string { return proto.CompactTextString(m) } 554 | func (*PropertyValue) ProtoMessage() {} 555 | 556 | func (m *PropertyValue) GetInt64Value() int64 { 557 | if m != nil && m.Int64Value != nil { 558 | return *m.Int64Value 559 | } 560 | return 0 561 | } 562 | 563 | func (m *PropertyValue) GetBooleanValue() bool { 564 | if m != nil && m.BooleanValue != nil { 565 | return *m.BooleanValue 566 | } 567 | return false 568 | } 569 | 570 | func (m *PropertyValue) GetStringValue() string { 571 | if m != nil && m.StringValue != nil { 572 | return *m.StringValue 573 | } 574 | return "" 575 | } 576 | 577 | func (m *PropertyValue) GetDoubleValue() float64 { 578 | if m != nil && m.DoubleValue != nil { 579 | return *m.DoubleValue 580 | } 581 | return 0 582 | } 583 | 584 | func (m *PropertyValue) GetPointvalue() *PropertyValue_PointValue { 585 | if m != nil { 586 | return m.Pointvalue 587 | } 588 | return nil 589 | } 590 | 591 | func (m *PropertyValue) GetUservalue() *PropertyValue_UserValue { 592 | if m != nil { 593 | return m.Uservalue 594 | } 595 | return nil 596 | } 597 | 598 | func (m *PropertyValue) GetReferencevalue() *PropertyValue_ReferenceValue { 599 | if m != nil { 600 | return m.Referencevalue 601 | } 602 | return nil 603 | } 604 | 605 | type PropertyValue_PointValue struct { 606 | X *float64 `protobuf:"fixed64,6,req,name=x" json:"x,omitempty"` 607 | Y *float64 `protobuf:"fixed64,7,req,name=y" json:"y,omitempty"` 608 | XXX_unrecognized []byte `json:"-"` 609 | } 610 | 611 | func (m *PropertyValue_PointValue) Reset() { *m = PropertyValue_PointValue{} } 612 | func (m *PropertyValue_PointValue) String() string { return proto.CompactTextString(m) } 613 | func (*PropertyValue_PointValue) ProtoMessage() {} 614 | 615 | func (m *PropertyValue_PointValue) GetX() float64 { 616 | if m != nil && m.X != nil { 617 | return *m.X 618 | } 619 | return 0 620 | } 621 | 622 | func (m *PropertyValue_PointValue) GetY() float64 { 623 | if m != nil && m.Y != nil { 624 | return *m.Y 625 | } 626 | return 0 627 | } 628 | 629 | type PropertyValue_UserValue struct { 630 | Email *string `protobuf:"bytes,9,req,name=email" json:"email,omitempty"` 631 | AuthDomain *string `protobuf:"bytes,10,req,name=auth_domain" json:"auth_domain,omitempty"` 632 | Nickname *string `protobuf:"bytes,11,opt,name=nickname" json:"nickname,omitempty"` 633 | FederatedIdentity *string `protobuf:"bytes,21,opt,name=federated_identity" json:"federated_identity,omitempty"` 634 | FederatedProvider *string `protobuf:"bytes,22,opt,name=federated_provider" json:"federated_provider,omitempty"` 635 | XXX_unrecognized []byte `json:"-"` 636 | } 637 | 638 | func (m *PropertyValue_UserValue) Reset() { *m = PropertyValue_UserValue{} } 639 | func (m *PropertyValue_UserValue) String() string { return proto.CompactTextString(m) } 640 | func (*PropertyValue_UserValue) ProtoMessage() {} 641 | 642 | func (m *PropertyValue_UserValue) GetEmail() string { 643 | if m != nil && m.Email != nil { 644 | return *m.Email 645 | } 646 | return "" 647 | } 648 | 649 | func (m *PropertyValue_UserValue) GetAuthDomain() string { 650 | if m != nil && m.AuthDomain != nil { 651 | return *m.AuthDomain 652 | } 653 | return "" 654 | } 655 | 656 | func (m *PropertyValue_UserValue) GetNickname() string { 657 | if m != nil && m.Nickname != nil { 658 | return *m.Nickname 659 | } 660 | return "" 661 | } 662 | 663 | func (m *PropertyValue_UserValue) GetFederatedIdentity() string { 664 | if m != nil && m.FederatedIdentity != nil { 665 | return *m.FederatedIdentity 666 | } 667 | return "" 668 | } 669 | 670 | func (m *PropertyValue_UserValue) GetFederatedProvider() string { 671 | if m != nil && m.FederatedProvider != nil { 672 | return *m.FederatedProvider 673 | } 674 | return "" 675 | } 676 | 677 | type PropertyValue_ReferenceValue struct { 678 | App *string `protobuf:"bytes,13,req,name=app" json:"app,omitempty"` 679 | NameSpace *string `protobuf:"bytes,20,opt,name=name_space" json:"name_space,omitempty"` 680 | Pathelement []*PropertyValue_ReferenceValue_PathElement `protobuf:"group,14,rep,name=PathElement" json:"pathelement,omitempty"` 681 | XXX_unrecognized []byte `json:"-"` 682 | } 683 | 684 | func (m *PropertyValue_ReferenceValue) Reset() { *m = PropertyValue_ReferenceValue{} } 685 | func (m *PropertyValue_ReferenceValue) String() string { return proto.CompactTextString(m) } 686 | func (*PropertyValue_ReferenceValue) ProtoMessage() {} 687 | 688 | func (m *PropertyValue_ReferenceValue) GetApp() string { 689 | if m != nil && m.App != nil { 690 | return *m.App 691 | } 692 | return "" 693 | } 694 | 695 | func (m *PropertyValue_ReferenceValue) GetNameSpace() string { 696 | if m != nil && m.NameSpace != nil { 697 | return *m.NameSpace 698 | } 699 | return "" 700 | } 701 | 702 | func (m *PropertyValue_ReferenceValue) GetPathelement() []*PropertyValue_ReferenceValue_PathElement { 703 | if m != nil { 704 | return m.Pathelement 705 | } 706 | return nil 707 | } 708 | 709 | type PropertyValue_ReferenceValue_PathElement struct { 710 | Type *string `protobuf:"bytes,15,req,name=type" json:"type,omitempty"` 711 | Id *int64 `protobuf:"varint,16,opt,name=id" json:"id,omitempty"` 712 | Name *string `protobuf:"bytes,17,opt,name=name" json:"name,omitempty"` 713 | XXX_unrecognized []byte `json:"-"` 714 | } 715 | 716 | func (m *PropertyValue_ReferenceValue_PathElement) Reset() { 717 | *m = PropertyValue_ReferenceValue_PathElement{} 718 | } 719 | func (m *PropertyValue_ReferenceValue_PathElement) String() string { return proto.CompactTextString(m) } 720 | func (*PropertyValue_ReferenceValue_PathElement) ProtoMessage() {} 721 | 722 | func (m *PropertyValue_ReferenceValue_PathElement) GetType() string { 723 | if m != nil && m.Type != nil { 724 | return *m.Type 725 | } 726 | return "" 727 | } 728 | 729 | func (m *PropertyValue_ReferenceValue_PathElement) GetId() int64 { 730 | if m != nil && m.Id != nil { 731 | return *m.Id 732 | } 733 | return 0 734 | } 735 | 736 | func (m *PropertyValue_ReferenceValue_PathElement) GetName() string { 737 | if m != nil && m.Name != nil { 738 | return *m.Name 739 | } 740 | return "" 741 | } 742 | 743 | type Property struct { 744 | Meaning *Property_Meaning `protobuf:"varint,1,opt,name=meaning,enum=appengine.Property_Meaning,def=0" json:"meaning,omitempty"` 745 | MeaningUri *string `protobuf:"bytes,2,opt,name=meaning_uri" json:"meaning_uri,omitempty"` 746 | Name *string `protobuf:"bytes,3,req,name=name" json:"name,omitempty"` 747 | Value *PropertyValue `protobuf:"bytes,5,req,name=value" json:"value,omitempty"` 748 | Multiple *bool `protobuf:"varint,4,req,name=multiple" json:"multiple,omitempty"` 749 | Searchable *bool `protobuf:"varint,6,opt,name=searchable,def=0" json:"searchable,omitempty"` 750 | FtsTokenizationOption *Property_FtsTokenizationOption `protobuf:"varint,8,opt,name=fts_tokenization_option,enum=appengine.Property_FtsTokenizationOption" json:"fts_tokenization_option,omitempty"` 751 | Locale *string `protobuf:"bytes,9,opt,name=locale,def=en" json:"locale,omitempty"` 752 | XXX_unrecognized []byte `json:"-"` 753 | } 754 | 755 | func (m *Property) Reset() { *m = Property{} } 756 | func (m *Property) String() string { return proto.CompactTextString(m) } 757 | func (*Property) ProtoMessage() {} 758 | 759 | const Default_Property_Meaning Property_Meaning = Property_NO_MEANING 760 | const Default_Property_Searchable bool = false 761 | const Default_Property_Locale string = "en" 762 | 763 | func (m *Property) GetMeaning() Property_Meaning { 764 | if m != nil && m.Meaning != nil { 765 | return *m.Meaning 766 | } 767 | return Default_Property_Meaning 768 | } 769 | 770 | func (m *Property) GetMeaningUri() string { 771 | if m != nil && m.MeaningUri != nil { 772 | return *m.MeaningUri 773 | } 774 | return "" 775 | } 776 | 777 | func (m *Property) GetName() string { 778 | if m != nil && m.Name != nil { 779 | return *m.Name 780 | } 781 | return "" 782 | } 783 | 784 | func (m *Property) GetValue() *PropertyValue { 785 | if m != nil { 786 | return m.Value 787 | } 788 | return nil 789 | } 790 | 791 | func (m *Property) GetMultiple() bool { 792 | if m != nil && m.Multiple != nil { 793 | return *m.Multiple 794 | } 795 | return false 796 | } 797 | 798 | func (m *Property) GetSearchable() bool { 799 | if m != nil && m.Searchable != nil { 800 | return *m.Searchable 801 | } 802 | return Default_Property_Searchable 803 | } 804 | 805 | func (m *Property) GetFtsTokenizationOption() Property_FtsTokenizationOption { 806 | if m != nil && m.FtsTokenizationOption != nil { 807 | return *m.FtsTokenizationOption 808 | } 809 | return Property_HTML 810 | } 811 | 812 | func (m *Property) GetLocale() string { 813 | if m != nil && m.Locale != nil { 814 | return *m.Locale 815 | } 816 | return Default_Property_Locale 817 | } 818 | 819 | type Path struct { 820 | Element []*Path_Element `protobuf:"group,1,rep,name=Element" json:"element,omitempty"` 821 | XXX_unrecognized []byte `json:"-"` 822 | } 823 | 824 | func (m *Path) Reset() { *m = Path{} } 825 | func (m *Path) String() string { return proto.CompactTextString(m) } 826 | func (*Path) ProtoMessage() {} 827 | 828 | func (m *Path) GetElement() []*Path_Element { 829 | if m != nil { 830 | return m.Element 831 | } 832 | return nil 833 | } 834 | 835 | type Path_Element struct { 836 | Type *string `protobuf:"bytes,2,req,name=type" json:"type,omitempty"` 837 | Id *int64 `protobuf:"varint,3,opt,name=id" json:"id,omitempty"` 838 | Name *string `protobuf:"bytes,4,opt,name=name" json:"name,omitempty"` 839 | XXX_unrecognized []byte `json:"-"` 840 | } 841 | 842 | func (m *Path_Element) Reset() { *m = Path_Element{} } 843 | func (m *Path_Element) String() string { return proto.CompactTextString(m) } 844 | func (*Path_Element) ProtoMessage() {} 845 | 846 | func (m *Path_Element) GetType() string { 847 | if m != nil && m.Type != nil { 848 | return *m.Type 849 | } 850 | return "" 851 | } 852 | 853 | func (m *Path_Element) GetId() int64 { 854 | if m != nil && m.Id != nil { 855 | return *m.Id 856 | } 857 | return 0 858 | } 859 | 860 | func (m *Path_Element) GetName() string { 861 | if m != nil && m.Name != nil { 862 | return *m.Name 863 | } 864 | return "" 865 | } 866 | 867 | type Reference struct { 868 | App *string `protobuf:"bytes,13,req,name=app" json:"app,omitempty"` 869 | NameSpace *string `protobuf:"bytes,20,opt,name=name_space" json:"name_space,omitempty"` 870 | Path *Path `protobuf:"bytes,14,req,name=path" json:"path,omitempty"` 871 | XXX_unrecognized []byte `json:"-"` 872 | } 873 | 874 | func (m *Reference) Reset() { *m = Reference{} } 875 | func (m *Reference) String() string { return proto.CompactTextString(m) } 876 | func (*Reference) ProtoMessage() {} 877 | 878 | func (m *Reference) GetApp() string { 879 | if m != nil && m.App != nil { 880 | return *m.App 881 | } 882 | return "" 883 | } 884 | 885 | func (m *Reference) GetNameSpace() string { 886 | if m != nil && m.NameSpace != nil { 887 | return *m.NameSpace 888 | } 889 | return "" 890 | } 891 | 892 | func (m *Reference) GetPath() *Path { 893 | if m != nil { 894 | return m.Path 895 | } 896 | return nil 897 | } 898 | 899 | type User struct { 900 | Email *string `protobuf:"bytes,1,req,name=email" json:"email,omitempty"` 901 | AuthDomain *string `protobuf:"bytes,2,req,name=auth_domain" json:"auth_domain,omitempty"` 902 | Nickname *string `protobuf:"bytes,3,opt,name=nickname" json:"nickname,omitempty"` 903 | FederatedIdentity *string `protobuf:"bytes,6,opt,name=federated_identity" json:"federated_identity,omitempty"` 904 | FederatedProvider *string `protobuf:"bytes,7,opt,name=federated_provider" json:"federated_provider,omitempty"` 905 | XXX_unrecognized []byte `json:"-"` 906 | } 907 | 908 | func (m *User) Reset() { *m = User{} } 909 | func (m *User) String() string { return proto.CompactTextString(m) } 910 | func (*User) ProtoMessage() {} 911 | 912 | func (m *User) GetEmail() string { 913 | if m != nil && m.Email != nil { 914 | return *m.Email 915 | } 916 | return "" 917 | } 918 | 919 | func (m *User) GetAuthDomain() string { 920 | if m != nil && m.AuthDomain != nil { 921 | return *m.AuthDomain 922 | } 923 | return "" 924 | } 925 | 926 | func (m *User) GetNickname() string { 927 | if m != nil && m.Nickname != nil { 928 | return *m.Nickname 929 | } 930 | return "" 931 | } 932 | 933 | func (m *User) GetFederatedIdentity() string { 934 | if m != nil && m.FederatedIdentity != nil { 935 | return *m.FederatedIdentity 936 | } 937 | return "" 938 | } 939 | 940 | func (m *User) GetFederatedProvider() string { 941 | if m != nil && m.FederatedProvider != nil { 942 | return *m.FederatedProvider 943 | } 944 | return "" 945 | } 946 | 947 | type EntityProto struct { 948 | Key *Reference `protobuf:"bytes,13,req,name=key" json:"key,omitempty"` 949 | EntityGroup *Path `protobuf:"bytes,16,req,name=entity_group" json:"entity_group,omitempty"` 950 | Owner *User `protobuf:"bytes,17,opt,name=owner" json:"owner,omitempty"` 951 | Kind *EntityProto_Kind `protobuf:"varint,4,opt,name=kind,enum=appengine.EntityProto_Kind" json:"kind,omitempty"` 952 | KindUri *string `protobuf:"bytes,5,opt,name=kind_uri" json:"kind_uri,omitempty"` 953 | Property []*Property `protobuf:"bytes,14,rep,name=property" json:"property,omitempty"` 954 | RawProperty []*Property `protobuf:"bytes,15,rep,name=raw_property" json:"raw_property,omitempty"` 955 | Rank *int32 `protobuf:"varint,18,opt,name=rank" json:"rank,omitempty"` 956 | XXX_unrecognized []byte `json:"-"` 957 | } 958 | 959 | func (m *EntityProto) Reset() { *m = EntityProto{} } 960 | func (m *EntityProto) String() string { return proto.CompactTextString(m) } 961 | func (*EntityProto) ProtoMessage() {} 962 | 963 | func (m *EntityProto) GetKey() *Reference { 964 | if m != nil { 965 | return m.Key 966 | } 967 | return nil 968 | } 969 | 970 | func (m *EntityProto) GetEntityGroup() *Path { 971 | if m != nil { 972 | return m.EntityGroup 973 | } 974 | return nil 975 | } 976 | 977 | func (m *EntityProto) GetOwner() *User { 978 | if m != nil { 979 | return m.Owner 980 | } 981 | return nil 982 | } 983 | 984 | func (m *EntityProto) GetKind() EntityProto_Kind { 985 | if m != nil && m.Kind != nil { 986 | return *m.Kind 987 | } 988 | return EntityProto_GD_CONTACT 989 | } 990 | 991 | func (m *EntityProto) GetKindUri() string { 992 | if m != nil && m.KindUri != nil { 993 | return *m.KindUri 994 | } 995 | return "" 996 | } 997 | 998 | func (m *EntityProto) GetProperty() []*Property { 999 | if m != nil { 1000 | return m.Property 1001 | } 1002 | return nil 1003 | } 1004 | 1005 | func (m *EntityProto) GetRawProperty() []*Property { 1006 | if m != nil { 1007 | return m.RawProperty 1008 | } 1009 | return nil 1010 | } 1011 | 1012 | func (m *EntityProto) GetRank() int32 { 1013 | if m != nil && m.Rank != nil { 1014 | return *m.Rank 1015 | } 1016 | return 0 1017 | } 1018 | 1019 | type CompositeProperty struct { 1020 | IndexId *int64 `protobuf:"varint,1,req,name=index_id" json:"index_id,omitempty"` 1021 | Value []string `protobuf:"bytes,2,rep,name=value" json:"value,omitempty"` 1022 | XXX_unrecognized []byte `json:"-"` 1023 | } 1024 | 1025 | func (m *CompositeProperty) Reset() { *m = CompositeProperty{} } 1026 | func (m *CompositeProperty) String() string { return proto.CompactTextString(m) } 1027 | func (*CompositeProperty) ProtoMessage() {} 1028 | 1029 | func (m *CompositeProperty) GetIndexId() int64 { 1030 | if m != nil && m.IndexId != nil { 1031 | return *m.IndexId 1032 | } 1033 | return 0 1034 | } 1035 | 1036 | func (m *CompositeProperty) GetValue() []string { 1037 | if m != nil { 1038 | return m.Value 1039 | } 1040 | return nil 1041 | } 1042 | 1043 | type Index struct { 1044 | EntityType *string `protobuf:"bytes,1,req,name=entity_type" json:"entity_type,omitempty"` 1045 | Ancestor *bool `protobuf:"varint,5,req,name=ancestor" json:"ancestor,omitempty"` 1046 | Property []*Index_Property `protobuf:"group,2,rep,name=Property" json:"property,omitempty"` 1047 | XXX_unrecognized []byte `json:"-"` 1048 | } 1049 | 1050 | func (m *Index) Reset() { *m = Index{} } 1051 | func (m *Index) String() string { return proto.CompactTextString(m) } 1052 | func (*Index) ProtoMessage() {} 1053 | 1054 | func (m *Index) GetEntityType() string { 1055 | if m != nil && m.EntityType != nil { 1056 | return *m.EntityType 1057 | } 1058 | return "" 1059 | } 1060 | 1061 | func (m *Index) GetAncestor() bool { 1062 | if m != nil && m.Ancestor != nil { 1063 | return *m.Ancestor 1064 | } 1065 | return false 1066 | } 1067 | 1068 | func (m *Index) GetProperty() []*Index_Property { 1069 | if m != nil { 1070 | return m.Property 1071 | } 1072 | return nil 1073 | } 1074 | 1075 | type Index_Property struct { 1076 | Name *string `protobuf:"bytes,3,req,name=name" json:"name,omitempty"` 1077 | Direction *Index_Property_Direction `protobuf:"varint,4,opt,name=direction,enum=appengine.Index_Property_Direction,def=1" json:"direction,omitempty"` 1078 | XXX_unrecognized []byte `json:"-"` 1079 | } 1080 | 1081 | func (m *Index_Property) Reset() { *m = Index_Property{} } 1082 | func (m *Index_Property) String() string { return proto.CompactTextString(m) } 1083 | func (*Index_Property) ProtoMessage() {} 1084 | 1085 | const Default_Index_Property_Direction Index_Property_Direction = Index_Property_ASCENDING 1086 | 1087 | func (m *Index_Property) GetName() string { 1088 | if m != nil && m.Name != nil { 1089 | return *m.Name 1090 | } 1091 | return "" 1092 | } 1093 | 1094 | func (m *Index_Property) GetDirection() Index_Property_Direction { 1095 | if m != nil && m.Direction != nil { 1096 | return *m.Direction 1097 | } 1098 | return Default_Index_Property_Direction 1099 | } 1100 | 1101 | type CompositeIndex struct { 1102 | AppId *string `protobuf:"bytes,1,req,name=app_id" json:"app_id,omitempty"` 1103 | Id *int64 `protobuf:"varint,2,req,name=id" json:"id,omitempty"` 1104 | Definition *Index `protobuf:"bytes,3,req,name=definition" json:"definition,omitempty"` 1105 | State *CompositeIndex_State `protobuf:"varint,4,req,name=state,enum=appengine.CompositeIndex_State" json:"state,omitempty"` 1106 | OnlyUseIfRequired *bool `protobuf:"varint,6,opt,name=only_use_if_required,def=0" json:"only_use_if_required,omitempty"` 1107 | XXX_unrecognized []byte `json:"-"` 1108 | } 1109 | 1110 | func (m *CompositeIndex) Reset() { *m = CompositeIndex{} } 1111 | func (m *CompositeIndex) String() string { return proto.CompactTextString(m) } 1112 | func (*CompositeIndex) ProtoMessage() {} 1113 | 1114 | const Default_CompositeIndex_OnlyUseIfRequired bool = false 1115 | 1116 | func (m *CompositeIndex) GetAppId() string { 1117 | if m != nil && m.AppId != nil { 1118 | return *m.AppId 1119 | } 1120 | return "" 1121 | } 1122 | 1123 | func (m *CompositeIndex) GetId() int64 { 1124 | if m != nil && m.Id != nil { 1125 | return *m.Id 1126 | } 1127 | return 0 1128 | } 1129 | 1130 | func (m *CompositeIndex) GetDefinition() *Index { 1131 | if m != nil { 1132 | return m.Definition 1133 | } 1134 | return nil 1135 | } 1136 | 1137 | func (m *CompositeIndex) GetState() CompositeIndex_State { 1138 | if m != nil && m.State != nil { 1139 | return *m.State 1140 | } 1141 | return CompositeIndex_WRITE_ONLY 1142 | } 1143 | 1144 | func (m *CompositeIndex) GetOnlyUseIfRequired() bool { 1145 | if m != nil && m.OnlyUseIfRequired != nil { 1146 | return *m.OnlyUseIfRequired 1147 | } 1148 | return Default_CompositeIndex_OnlyUseIfRequired 1149 | } 1150 | 1151 | type IndexPostfix struct { 1152 | IndexValue []*IndexPostfix_IndexValue `protobuf:"bytes,1,rep,name=index_value" json:"index_value,omitempty"` 1153 | Key *Reference `protobuf:"bytes,2,opt,name=key" json:"key,omitempty"` 1154 | Before *bool `protobuf:"varint,3,opt,name=before,def=1" json:"before,omitempty"` 1155 | XXX_unrecognized []byte `json:"-"` 1156 | } 1157 | 1158 | func (m *IndexPostfix) Reset() { *m = IndexPostfix{} } 1159 | func (m *IndexPostfix) String() string { return proto.CompactTextString(m) } 1160 | func (*IndexPostfix) ProtoMessage() {} 1161 | 1162 | const Default_IndexPostfix_Before bool = true 1163 | 1164 | func (m *IndexPostfix) GetIndexValue() []*IndexPostfix_IndexValue { 1165 | if m != nil { 1166 | return m.IndexValue 1167 | } 1168 | return nil 1169 | } 1170 | 1171 | func (m *IndexPostfix) GetKey() *Reference { 1172 | if m != nil { 1173 | return m.Key 1174 | } 1175 | return nil 1176 | } 1177 | 1178 | func (m *IndexPostfix) GetBefore() bool { 1179 | if m != nil && m.Before != nil { 1180 | return *m.Before 1181 | } 1182 | return Default_IndexPostfix_Before 1183 | } 1184 | 1185 | type IndexPostfix_IndexValue struct { 1186 | PropertyName *string `protobuf:"bytes,1,req,name=property_name" json:"property_name,omitempty"` 1187 | Value *PropertyValue `protobuf:"bytes,2,req,name=value" json:"value,omitempty"` 1188 | XXX_unrecognized []byte `json:"-"` 1189 | } 1190 | 1191 | func (m *IndexPostfix_IndexValue) Reset() { *m = IndexPostfix_IndexValue{} } 1192 | func (m *IndexPostfix_IndexValue) String() string { return proto.CompactTextString(m) } 1193 | func (*IndexPostfix_IndexValue) ProtoMessage() {} 1194 | 1195 | func (m *IndexPostfix_IndexValue) GetPropertyName() string { 1196 | if m != nil && m.PropertyName != nil { 1197 | return *m.PropertyName 1198 | } 1199 | return "" 1200 | } 1201 | 1202 | func (m *IndexPostfix_IndexValue) GetValue() *PropertyValue { 1203 | if m != nil { 1204 | return m.Value 1205 | } 1206 | return nil 1207 | } 1208 | 1209 | type IndexPosition struct { 1210 | Key *string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` 1211 | Before *bool `protobuf:"varint,2,opt,name=before,def=1" json:"before,omitempty"` 1212 | XXX_unrecognized []byte `json:"-"` 1213 | } 1214 | 1215 | func (m *IndexPosition) Reset() { *m = IndexPosition{} } 1216 | func (m *IndexPosition) String() string { return proto.CompactTextString(m) } 1217 | func (*IndexPosition) ProtoMessage() {} 1218 | 1219 | const Default_IndexPosition_Before bool = true 1220 | 1221 | func (m *IndexPosition) GetKey() string { 1222 | if m != nil && m.Key != nil { 1223 | return *m.Key 1224 | } 1225 | return "" 1226 | } 1227 | 1228 | func (m *IndexPosition) GetBefore() bool { 1229 | if m != nil && m.Before != nil { 1230 | return *m.Before 1231 | } 1232 | return Default_IndexPosition_Before 1233 | } 1234 | 1235 | type Snapshot struct { 1236 | Ts *int64 `protobuf:"varint,1,req,name=ts" json:"ts,omitempty"` 1237 | XXX_unrecognized []byte `json:"-"` 1238 | } 1239 | 1240 | func (m *Snapshot) Reset() { *m = Snapshot{} } 1241 | func (m *Snapshot) String() string { return proto.CompactTextString(m) } 1242 | func (*Snapshot) ProtoMessage() {} 1243 | 1244 | func (m *Snapshot) GetTs() int64 { 1245 | if m != nil && m.Ts != nil { 1246 | return *m.Ts 1247 | } 1248 | return 0 1249 | } 1250 | 1251 | type InternalHeader struct { 1252 | Qos *string `protobuf:"bytes,1,opt,name=qos" json:"qos,omitempty"` 1253 | XXX_unrecognized []byte `json:"-"` 1254 | } 1255 | 1256 | func (m *InternalHeader) Reset() { *m = InternalHeader{} } 1257 | func (m *InternalHeader) String() string { return proto.CompactTextString(m) } 1258 | func (*InternalHeader) ProtoMessage() {} 1259 | 1260 | func (m *InternalHeader) GetQos() string { 1261 | if m != nil && m.Qos != nil { 1262 | return *m.Qos 1263 | } 1264 | return "" 1265 | } 1266 | 1267 | type Transaction struct { 1268 | Header *InternalHeader `protobuf:"bytes,4,opt,name=header" json:"header,omitempty"` 1269 | Handle *uint64 `protobuf:"fixed64,1,req,name=handle" json:"handle,omitempty"` 1270 | App *string `protobuf:"bytes,2,req,name=app" json:"app,omitempty"` 1271 | MarkChanges *bool `protobuf:"varint,3,opt,name=mark_changes,def=0" json:"mark_changes,omitempty"` 1272 | XXX_unrecognized []byte `json:"-"` 1273 | } 1274 | 1275 | func (m *Transaction) Reset() { *m = Transaction{} } 1276 | func (m *Transaction) String() string { return proto.CompactTextString(m) } 1277 | func (*Transaction) ProtoMessage() {} 1278 | 1279 | const Default_Transaction_MarkChanges bool = false 1280 | 1281 | func (m *Transaction) GetHeader() *InternalHeader { 1282 | if m != nil { 1283 | return m.Header 1284 | } 1285 | return nil 1286 | } 1287 | 1288 | func (m *Transaction) GetHandle() uint64 { 1289 | if m != nil && m.Handle != nil { 1290 | return *m.Handle 1291 | } 1292 | return 0 1293 | } 1294 | 1295 | func (m *Transaction) GetApp() string { 1296 | if m != nil && m.App != nil { 1297 | return *m.App 1298 | } 1299 | return "" 1300 | } 1301 | 1302 | func (m *Transaction) GetMarkChanges() bool { 1303 | if m != nil && m.MarkChanges != nil { 1304 | return *m.MarkChanges 1305 | } 1306 | return Default_Transaction_MarkChanges 1307 | } 1308 | 1309 | type Query struct { 1310 | Header *InternalHeader `protobuf:"bytes,39,opt,name=header" json:"header,omitempty"` 1311 | App *string `protobuf:"bytes,1,req,name=app" json:"app,omitempty"` 1312 | NameSpace *string `protobuf:"bytes,29,opt,name=name_space" json:"name_space,omitempty"` 1313 | Kind *string `protobuf:"bytes,3,opt,name=kind" json:"kind,omitempty"` 1314 | Ancestor *Reference `protobuf:"bytes,17,opt,name=ancestor" json:"ancestor,omitempty"` 1315 | Filter []*Query_Filter `protobuf:"group,4,rep,name=Filter" json:"filter,omitempty"` 1316 | SearchQuery *string `protobuf:"bytes,8,opt,name=search_query" json:"search_query,omitempty"` 1317 | Order []*Query_Order `protobuf:"group,9,rep,name=Order" json:"order,omitempty"` 1318 | Hint *Query_Hint `protobuf:"varint,18,opt,name=hint,enum=appengine.Query_Hint" json:"hint,omitempty"` 1319 | Count *int32 `protobuf:"varint,23,opt,name=count" json:"count,omitempty"` 1320 | Offset *int32 `protobuf:"varint,12,opt,name=offset,def=0" json:"offset,omitempty"` 1321 | Limit *int32 `protobuf:"varint,16,opt,name=limit" json:"limit,omitempty"` 1322 | CompiledCursor *CompiledCursor `protobuf:"bytes,30,opt,name=compiled_cursor" json:"compiled_cursor,omitempty"` 1323 | EndCompiledCursor *CompiledCursor `protobuf:"bytes,31,opt,name=end_compiled_cursor" json:"end_compiled_cursor,omitempty"` 1324 | CompositeIndex []*CompositeIndex `protobuf:"bytes,19,rep,name=composite_index" json:"composite_index,omitempty"` 1325 | RequirePerfectPlan *bool `protobuf:"varint,20,opt,name=require_perfect_plan,def=0" json:"require_perfect_plan,omitempty"` 1326 | KeysOnly *bool `protobuf:"varint,21,opt,name=keys_only,def=0" json:"keys_only,omitempty"` 1327 | Transaction *Transaction `protobuf:"bytes,22,opt,name=transaction" json:"transaction,omitempty"` 1328 | Compile *bool `protobuf:"varint,25,opt,name=compile,def=0" json:"compile,omitempty"` 1329 | FailoverMs *int64 `protobuf:"varint,26,opt,name=failover_ms" json:"failover_ms,omitempty"` 1330 | Strong *bool `protobuf:"varint,32,opt,name=strong" json:"strong,omitempty"` 1331 | PropertyName []string `protobuf:"bytes,33,rep,name=property_name" json:"property_name,omitempty"` 1332 | GroupByPropertyName []string `protobuf:"bytes,34,rep,name=group_by_property_name" json:"group_by_property_name,omitempty"` 1333 | Distinct *bool `protobuf:"varint,24,opt,name=distinct" json:"distinct,omitempty"` 1334 | MinSafeTimeSeconds *int64 `protobuf:"varint,35,opt,name=min_safe_time_seconds" json:"min_safe_time_seconds,omitempty"` 1335 | SafeReplicaName []string `protobuf:"bytes,36,rep,name=safe_replica_name" json:"safe_replica_name,omitempty"` 1336 | PersistOffset *bool `protobuf:"varint,37,opt,name=persist_offset,def=0" json:"persist_offset,omitempty"` 1337 | XXX_unrecognized []byte `json:"-"` 1338 | } 1339 | 1340 | func (m *Query) Reset() { *m = Query{} } 1341 | func (m *Query) String() string { return proto.CompactTextString(m) } 1342 | func (*Query) ProtoMessage() {} 1343 | 1344 | const Default_Query_Offset int32 = 0 1345 | const Default_Query_RequirePerfectPlan bool = false 1346 | const Default_Query_KeysOnly bool = false 1347 | const Default_Query_Compile bool = false 1348 | const Default_Query_PersistOffset bool = false 1349 | 1350 | func (m *Query) GetHeader() *InternalHeader { 1351 | if m != nil { 1352 | return m.Header 1353 | } 1354 | return nil 1355 | } 1356 | 1357 | func (m *Query) GetApp() string { 1358 | if m != nil && m.App != nil { 1359 | return *m.App 1360 | } 1361 | return "" 1362 | } 1363 | 1364 | func (m *Query) GetNameSpace() string { 1365 | if m != nil && m.NameSpace != nil { 1366 | return *m.NameSpace 1367 | } 1368 | return "" 1369 | } 1370 | 1371 | func (m *Query) GetKind() string { 1372 | if m != nil && m.Kind != nil { 1373 | return *m.Kind 1374 | } 1375 | return "" 1376 | } 1377 | 1378 | func (m *Query) GetAncestor() *Reference { 1379 | if m != nil { 1380 | return m.Ancestor 1381 | } 1382 | return nil 1383 | } 1384 | 1385 | func (m *Query) GetFilter() []*Query_Filter { 1386 | if m != nil { 1387 | return m.Filter 1388 | } 1389 | return nil 1390 | } 1391 | 1392 | func (m *Query) GetSearchQuery() string { 1393 | if m != nil && m.SearchQuery != nil { 1394 | return *m.SearchQuery 1395 | } 1396 | return "" 1397 | } 1398 | 1399 | func (m *Query) GetOrder() []*Query_Order { 1400 | if m != nil { 1401 | return m.Order 1402 | } 1403 | return nil 1404 | } 1405 | 1406 | func (m *Query) GetHint() Query_Hint { 1407 | if m != nil && m.Hint != nil { 1408 | return *m.Hint 1409 | } 1410 | return Query_ORDER_FIRST 1411 | } 1412 | 1413 | func (m *Query) GetCount() int32 { 1414 | if m != nil && m.Count != nil { 1415 | return *m.Count 1416 | } 1417 | return 0 1418 | } 1419 | 1420 | func (m *Query) GetOffset() int32 { 1421 | if m != nil && m.Offset != nil { 1422 | return *m.Offset 1423 | } 1424 | return Default_Query_Offset 1425 | } 1426 | 1427 | func (m *Query) GetLimit() int32 { 1428 | if m != nil && m.Limit != nil { 1429 | return *m.Limit 1430 | } 1431 | return 0 1432 | } 1433 | 1434 | func (m *Query) GetCompiledCursor() *CompiledCursor { 1435 | if m != nil { 1436 | return m.CompiledCursor 1437 | } 1438 | return nil 1439 | } 1440 | 1441 | func (m *Query) GetEndCompiledCursor() *CompiledCursor { 1442 | if m != nil { 1443 | return m.EndCompiledCursor 1444 | } 1445 | return nil 1446 | } 1447 | 1448 | func (m *Query) GetCompositeIndex() []*CompositeIndex { 1449 | if m != nil { 1450 | return m.CompositeIndex 1451 | } 1452 | return nil 1453 | } 1454 | 1455 | func (m *Query) GetRequirePerfectPlan() bool { 1456 | if m != nil && m.RequirePerfectPlan != nil { 1457 | return *m.RequirePerfectPlan 1458 | } 1459 | return Default_Query_RequirePerfectPlan 1460 | } 1461 | 1462 | func (m *Query) GetKeysOnly() bool { 1463 | if m != nil && m.KeysOnly != nil { 1464 | return *m.KeysOnly 1465 | } 1466 | return Default_Query_KeysOnly 1467 | } 1468 | 1469 | func (m *Query) GetTransaction() *Transaction { 1470 | if m != nil { 1471 | return m.Transaction 1472 | } 1473 | return nil 1474 | } 1475 | 1476 | func (m *Query) GetCompile() bool { 1477 | if m != nil && m.Compile != nil { 1478 | return *m.Compile 1479 | } 1480 | return Default_Query_Compile 1481 | } 1482 | 1483 | func (m *Query) GetFailoverMs() int64 { 1484 | if m != nil && m.FailoverMs != nil { 1485 | return *m.FailoverMs 1486 | } 1487 | return 0 1488 | } 1489 | 1490 | func (m *Query) GetStrong() bool { 1491 | if m != nil && m.Strong != nil { 1492 | return *m.Strong 1493 | } 1494 | return false 1495 | } 1496 | 1497 | func (m *Query) GetPropertyName() []string { 1498 | if m != nil { 1499 | return m.PropertyName 1500 | } 1501 | return nil 1502 | } 1503 | 1504 | func (m *Query) GetGroupByPropertyName() []string { 1505 | if m != nil { 1506 | return m.GroupByPropertyName 1507 | } 1508 | return nil 1509 | } 1510 | 1511 | func (m *Query) GetDistinct() bool { 1512 | if m != nil && m.Distinct != nil { 1513 | return *m.Distinct 1514 | } 1515 | return false 1516 | } 1517 | 1518 | func (m *Query) GetMinSafeTimeSeconds() int64 { 1519 | if m != nil && m.MinSafeTimeSeconds != nil { 1520 | return *m.MinSafeTimeSeconds 1521 | } 1522 | return 0 1523 | } 1524 | 1525 | func (m *Query) GetSafeReplicaName() []string { 1526 | if m != nil { 1527 | return m.SafeReplicaName 1528 | } 1529 | return nil 1530 | } 1531 | 1532 | func (m *Query) GetPersistOffset() bool { 1533 | if m != nil && m.PersistOffset != nil { 1534 | return *m.PersistOffset 1535 | } 1536 | return Default_Query_PersistOffset 1537 | } 1538 | 1539 | type Query_Filter struct { 1540 | Op *Query_Filter_Operator `protobuf:"varint,6,req,name=op,enum=appengine.Query_Filter_Operator" json:"op,omitempty"` 1541 | Property []*Property `protobuf:"bytes,14,rep,name=property" json:"property,omitempty"` 1542 | XXX_unrecognized []byte `json:"-"` 1543 | } 1544 | 1545 | func (m *Query_Filter) Reset() { *m = Query_Filter{} } 1546 | func (m *Query_Filter) String() string { return proto.CompactTextString(m) } 1547 | func (*Query_Filter) ProtoMessage() {} 1548 | 1549 | func (m *Query_Filter) GetOp() Query_Filter_Operator { 1550 | if m != nil && m.Op != nil { 1551 | return *m.Op 1552 | } 1553 | return Query_Filter_LESS_THAN 1554 | } 1555 | 1556 | func (m *Query_Filter) GetProperty() []*Property { 1557 | if m != nil { 1558 | return m.Property 1559 | } 1560 | return nil 1561 | } 1562 | 1563 | type Query_Order struct { 1564 | Property *string `protobuf:"bytes,10,req,name=property" json:"property,omitempty"` 1565 | Direction *Query_Order_Direction `protobuf:"varint,11,opt,name=direction,enum=appengine.Query_Order_Direction,def=1" json:"direction,omitempty"` 1566 | XXX_unrecognized []byte `json:"-"` 1567 | } 1568 | 1569 | func (m *Query_Order) Reset() { *m = Query_Order{} } 1570 | func (m *Query_Order) String() string { return proto.CompactTextString(m) } 1571 | func (*Query_Order) ProtoMessage() {} 1572 | 1573 | const Default_Query_Order_Direction Query_Order_Direction = Query_Order_ASCENDING 1574 | 1575 | func (m *Query_Order) GetProperty() string { 1576 | if m != nil && m.Property != nil { 1577 | return *m.Property 1578 | } 1579 | return "" 1580 | } 1581 | 1582 | func (m *Query_Order) GetDirection() Query_Order_Direction { 1583 | if m != nil && m.Direction != nil { 1584 | return *m.Direction 1585 | } 1586 | return Default_Query_Order_Direction 1587 | } 1588 | 1589 | type CompiledQuery struct { 1590 | Primaryscan *CompiledQuery_PrimaryScan `protobuf:"group,1,req,name=PrimaryScan" json:"primaryscan,omitempty"` 1591 | Mergejoinscan []*CompiledQuery_MergeJoinScan `protobuf:"group,7,rep,name=MergeJoinScan" json:"mergejoinscan,omitempty"` 1592 | IndexDef *Index `protobuf:"bytes,21,opt,name=index_def" json:"index_def,omitempty"` 1593 | Offset *int32 `protobuf:"varint,10,opt,name=offset,def=0" json:"offset,omitempty"` 1594 | Limit *int32 `protobuf:"varint,11,opt,name=limit" json:"limit,omitempty"` 1595 | KeysOnly *bool `protobuf:"varint,12,req,name=keys_only" json:"keys_only,omitempty"` 1596 | PropertyName []string `protobuf:"bytes,24,rep,name=property_name" json:"property_name,omitempty"` 1597 | DistinctInfixSize *int32 `protobuf:"varint,25,opt,name=distinct_infix_size" json:"distinct_infix_size,omitempty"` 1598 | Entityfilter *CompiledQuery_EntityFilter `protobuf:"group,13,opt,name=EntityFilter" json:"entityfilter,omitempty"` 1599 | XXX_unrecognized []byte `json:"-"` 1600 | } 1601 | 1602 | func (m *CompiledQuery) Reset() { *m = CompiledQuery{} } 1603 | func (m *CompiledQuery) String() string { return proto.CompactTextString(m) } 1604 | func (*CompiledQuery) ProtoMessage() {} 1605 | 1606 | const Default_CompiledQuery_Offset int32 = 0 1607 | 1608 | func (m *CompiledQuery) GetPrimaryscan() *CompiledQuery_PrimaryScan { 1609 | if m != nil { 1610 | return m.Primaryscan 1611 | } 1612 | return nil 1613 | } 1614 | 1615 | func (m *CompiledQuery) GetMergejoinscan() []*CompiledQuery_MergeJoinScan { 1616 | if m != nil { 1617 | return m.Mergejoinscan 1618 | } 1619 | return nil 1620 | } 1621 | 1622 | func (m *CompiledQuery) GetIndexDef() *Index { 1623 | if m != nil { 1624 | return m.IndexDef 1625 | } 1626 | return nil 1627 | } 1628 | 1629 | func (m *CompiledQuery) GetOffset() int32 { 1630 | if m != nil && m.Offset != nil { 1631 | return *m.Offset 1632 | } 1633 | return Default_CompiledQuery_Offset 1634 | } 1635 | 1636 | func (m *CompiledQuery) GetLimit() int32 { 1637 | if m != nil && m.Limit != nil { 1638 | return *m.Limit 1639 | } 1640 | return 0 1641 | } 1642 | 1643 | func (m *CompiledQuery) GetKeysOnly() bool { 1644 | if m != nil && m.KeysOnly != nil { 1645 | return *m.KeysOnly 1646 | } 1647 | return false 1648 | } 1649 | 1650 | func (m *CompiledQuery) GetPropertyName() []string { 1651 | if m != nil { 1652 | return m.PropertyName 1653 | } 1654 | return nil 1655 | } 1656 | 1657 | func (m *CompiledQuery) GetDistinctInfixSize() int32 { 1658 | if m != nil && m.DistinctInfixSize != nil { 1659 | return *m.DistinctInfixSize 1660 | } 1661 | return 0 1662 | } 1663 | 1664 | func (m *CompiledQuery) GetEntityfilter() *CompiledQuery_EntityFilter { 1665 | if m != nil { 1666 | return m.Entityfilter 1667 | } 1668 | return nil 1669 | } 1670 | 1671 | type CompiledQuery_PrimaryScan struct { 1672 | IndexName *string `protobuf:"bytes,2,opt,name=index_name" json:"index_name,omitempty"` 1673 | StartKey *string `protobuf:"bytes,3,opt,name=start_key" json:"start_key,omitempty"` 1674 | StartInclusive *bool `protobuf:"varint,4,opt,name=start_inclusive" json:"start_inclusive,omitempty"` 1675 | EndKey *string `protobuf:"bytes,5,opt,name=end_key" json:"end_key,omitempty"` 1676 | EndInclusive *bool `protobuf:"varint,6,opt,name=end_inclusive" json:"end_inclusive,omitempty"` 1677 | StartPostfixValue []string `protobuf:"bytes,22,rep,name=start_postfix_value" json:"start_postfix_value,omitempty"` 1678 | EndPostfixValue []string `protobuf:"bytes,23,rep,name=end_postfix_value" json:"end_postfix_value,omitempty"` 1679 | EndUnappliedLogTimestampUs *int64 `protobuf:"varint,19,opt,name=end_unapplied_log_timestamp_us" json:"end_unapplied_log_timestamp_us,omitempty"` 1680 | XXX_unrecognized []byte `json:"-"` 1681 | } 1682 | 1683 | func (m *CompiledQuery_PrimaryScan) Reset() { *m = CompiledQuery_PrimaryScan{} } 1684 | func (m *CompiledQuery_PrimaryScan) String() string { return proto.CompactTextString(m) } 1685 | func (*CompiledQuery_PrimaryScan) ProtoMessage() {} 1686 | 1687 | func (m *CompiledQuery_PrimaryScan) GetIndexName() string { 1688 | if m != nil && m.IndexName != nil { 1689 | return *m.IndexName 1690 | } 1691 | return "" 1692 | } 1693 | 1694 | func (m *CompiledQuery_PrimaryScan) GetStartKey() string { 1695 | if m != nil && m.StartKey != nil { 1696 | return *m.StartKey 1697 | } 1698 | return "" 1699 | } 1700 | 1701 | func (m *CompiledQuery_PrimaryScan) GetStartInclusive() bool { 1702 | if m != nil && m.StartInclusive != nil { 1703 | return *m.StartInclusive 1704 | } 1705 | return false 1706 | } 1707 | 1708 | func (m *CompiledQuery_PrimaryScan) GetEndKey() string { 1709 | if m != nil && m.EndKey != nil { 1710 | return *m.EndKey 1711 | } 1712 | return "" 1713 | } 1714 | 1715 | func (m *CompiledQuery_PrimaryScan) GetEndInclusive() bool { 1716 | if m != nil && m.EndInclusive != nil { 1717 | return *m.EndInclusive 1718 | } 1719 | return false 1720 | } 1721 | 1722 | func (m *CompiledQuery_PrimaryScan) GetStartPostfixValue() []string { 1723 | if m != nil { 1724 | return m.StartPostfixValue 1725 | } 1726 | return nil 1727 | } 1728 | 1729 | func (m *CompiledQuery_PrimaryScan) GetEndPostfixValue() []string { 1730 | if m != nil { 1731 | return m.EndPostfixValue 1732 | } 1733 | return nil 1734 | } 1735 | 1736 | func (m *CompiledQuery_PrimaryScan) GetEndUnappliedLogTimestampUs() int64 { 1737 | if m != nil && m.EndUnappliedLogTimestampUs != nil { 1738 | return *m.EndUnappliedLogTimestampUs 1739 | } 1740 | return 0 1741 | } 1742 | 1743 | type CompiledQuery_MergeJoinScan struct { 1744 | IndexName *string `protobuf:"bytes,8,req,name=index_name" json:"index_name,omitempty"` 1745 | PrefixValue []string `protobuf:"bytes,9,rep,name=prefix_value" json:"prefix_value,omitempty"` 1746 | ValuePrefix *bool `protobuf:"varint,20,opt,name=value_prefix,def=0" json:"value_prefix,omitempty"` 1747 | XXX_unrecognized []byte `json:"-"` 1748 | } 1749 | 1750 | func (m *CompiledQuery_MergeJoinScan) Reset() { *m = CompiledQuery_MergeJoinScan{} } 1751 | func (m *CompiledQuery_MergeJoinScan) String() string { return proto.CompactTextString(m) } 1752 | func (*CompiledQuery_MergeJoinScan) ProtoMessage() {} 1753 | 1754 | const Default_CompiledQuery_MergeJoinScan_ValuePrefix bool = false 1755 | 1756 | func (m *CompiledQuery_MergeJoinScan) GetIndexName() string { 1757 | if m != nil && m.IndexName != nil { 1758 | return *m.IndexName 1759 | } 1760 | return "" 1761 | } 1762 | 1763 | func (m *CompiledQuery_MergeJoinScan) GetPrefixValue() []string { 1764 | if m != nil { 1765 | return m.PrefixValue 1766 | } 1767 | return nil 1768 | } 1769 | 1770 | func (m *CompiledQuery_MergeJoinScan) GetValuePrefix() bool { 1771 | if m != nil && m.ValuePrefix != nil { 1772 | return *m.ValuePrefix 1773 | } 1774 | return Default_CompiledQuery_MergeJoinScan_ValuePrefix 1775 | } 1776 | 1777 | type CompiledQuery_EntityFilter struct { 1778 | Distinct *bool `protobuf:"varint,14,opt,name=distinct,def=0" json:"distinct,omitempty"` 1779 | Kind *string `protobuf:"bytes,17,opt,name=kind" json:"kind,omitempty"` 1780 | Ancestor *Reference `protobuf:"bytes,18,opt,name=ancestor" json:"ancestor,omitempty"` 1781 | XXX_unrecognized []byte `json:"-"` 1782 | } 1783 | 1784 | func (m *CompiledQuery_EntityFilter) Reset() { *m = CompiledQuery_EntityFilter{} } 1785 | func (m *CompiledQuery_EntityFilter) String() string { return proto.CompactTextString(m) } 1786 | func (*CompiledQuery_EntityFilter) ProtoMessage() {} 1787 | 1788 | const Default_CompiledQuery_EntityFilter_Distinct bool = false 1789 | 1790 | func (m *CompiledQuery_EntityFilter) GetDistinct() bool { 1791 | if m != nil && m.Distinct != nil { 1792 | return *m.Distinct 1793 | } 1794 | return Default_CompiledQuery_EntityFilter_Distinct 1795 | } 1796 | 1797 | func (m *CompiledQuery_EntityFilter) GetKind() string { 1798 | if m != nil && m.Kind != nil { 1799 | return *m.Kind 1800 | } 1801 | return "" 1802 | } 1803 | 1804 | func (m *CompiledQuery_EntityFilter) GetAncestor() *Reference { 1805 | if m != nil { 1806 | return m.Ancestor 1807 | } 1808 | return nil 1809 | } 1810 | 1811 | type CompiledCursor struct { 1812 | Position *CompiledCursor_Position `protobuf:"group,2,opt,name=Position" json:"position,omitempty"` 1813 | XXX_unrecognized []byte `json:"-"` 1814 | } 1815 | 1816 | func (m *CompiledCursor) Reset() { *m = CompiledCursor{} } 1817 | func (m *CompiledCursor) String() string { return proto.CompactTextString(m) } 1818 | func (*CompiledCursor) ProtoMessage() {} 1819 | 1820 | func (m *CompiledCursor) GetPosition() *CompiledCursor_Position { 1821 | if m != nil { 1822 | return m.Position 1823 | } 1824 | return nil 1825 | } 1826 | 1827 | type CompiledCursor_Position struct { 1828 | StartKey *string `protobuf:"bytes,27,opt,name=start_key" json:"start_key,omitempty"` 1829 | Indexvalue []*CompiledCursor_Position_IndexValue `protobuf:"group,29,rep,name=IndexValue" json:"indexvalue,omitempty"` 1830 | Key *Reference `protobuf:"bytes,32,opt,name=key" json:"key,omitempty"` 1831 | StartInclusive *bool `protobuf:"varint,28,opt,name=start_inclusive,def=1" json:"start_inclusive,omitempty"` 1832 | XXX_unrecognized []byte `json:"-"` 1833 | } 1834 | 1835 | func (m *CompiledCursor_Position) Reset() { *m = CompiledCursor_Position{} } 1836 | func (m *CompiledCursor_Position) String() string { return proto.CompactTextString(m) } 1837 | func (*CompiledCursor_Position) ProtoMessage() {} 1838 | 1839 | const Default_CompiledCursor_Position_StartInclusive bool = true 1840 | 1841 | func (m *CompiledCursor_Position) GetStartKey() string { 1842 | if m != nil && m.StartKey != nil { 1843 | return *m.StartKey 1844 | } 1845 | return "" 1846 | } 1847 | 1848 | func (m *CompiledCursor_Position) GetIndexvalue() []*CompiledCursor_Position_IndexValue { 1849 | if m != nil { 1850 | return m.Indexvalue 1851 | } 1852 | return nil 1853 | } 1854 | 1855 | func (m *CompiledCursor_Position) GetKey() *Reference { 1856 | if m != nil { 1857 | return m.Key 1858 | } 1859 | return nil 1860 | } 1861 | 1862 | func (m *CompiledCursor_Position) GetStartInclusive() bool { 1863 | if m != nil && m.StartInclusive != nil { 1864 | return *m.StartInclusive 1865 | } 1866 | return Default_CompiledCursor_Position_StartInclusive 1867 | } 1868 | 1869 | type CompiledCursor_Position_IndexValue struct { 1870 | Property *string `protobuf:"bytes,30,opt,name=property" json:"property,omitempty"` 1871 | Value *PropertyValue `protobuf:"bytes,31,req,name=value" json:"value,omitempty"` 1872 | XXX_unrecognized []byte `json:"-"` 1873 | } 1874 | 1875 | func (m *CompiledCursor_Position_IndexValue) Reset() { *m = CompiledCursor_Position_IndexValue{} } 1876 | func (m *CompiledCursor_Position_IndexValue) String() string { return proto.CompactTextString(m) } 1877 | func (*CompiledCursor_Position_IndexValue) ProtoMessage() {} 1878 | 1879 | func (m *CompiledCursor_Position_IndexValue) GetProperty() string { 1880 | if m != nil && m.Property != nil { 1881 | return *m.Property 1882 | } 1883 | return "" 1884 | } 1885 | 1886 | func (m *CompiledCursor_Position_IndexValue) GetValue() *PropertyValue { 1887 | if m != nil { 1888 | return m.Value 1889 | } 1890 | return nil 1891 | } 1892 | 1893 | type Cursor struct { 1894 | Cursor *uint64 `protobuf:"fixed64,1,req,name=cursor" json:"cursor,omitempty"` 1895 | App *string `protobuf:"bytes,2,opt,name=app" json:"app,omitempty"` 1896 | XXX_unrecognized []byte `json:"-"` 1897 | } 1898 | 1899 | func (m *Cursor) Reset() { *m = Cursor{} } 1900 | func (m *Cursor) String() string { return proto.CompactTextString(m) } 1901 | func (*Cursor) ProtoMessage() {} 1902 | 1903 | func (m *Cursor) GetCursor() uint64 { 1904 | if m != nil && m.Cursor != nil { 1905 | return *m.Cursor 1906 | } 1907 | return 0 1908 | } 1909 | 1910 | func (m *Cursor) GetApp() string { 1911 | if m != nil && m.App != nil { 1912 | return *m.App 1913 | } 1914 | return "" 1915 | } 1916 | 1917 | type Error struct { 1918 | XXX_unrecognized []byte `json:"-"` 1919 | } 1920 | 1921 | func (m *Error) Reset() { *m = Error{} } 1922 | func (m *Error) String() string { return proto.CompactTextString(m) } 1923 | func (*Error) ProtoMessage() {} 1924 | 1925 | type Cost struct { 1926 | IndexWrites *int32 `protobuf:"varint,1,opt,name=index_writes" json:"index_writes,omitempty"` 1927 | IndexWriteBytes *int32 `protobuf:"varint,2,opt,name=index_write_bytes" json:"index_write_bytes,omitempty"` 1928 | EntityWrites *int32 `protobuf:"varint,3,opt,name=entity_writes" json:"entity_writes,omitempty"` 1929 | EntityWriteBytes *int32 `protobuf:"varint,4,opt,name=entity_write_bytes" json:"entity_write_bytes,omitempty"` 1930 | Commitcost *Cost_CommitCost `protobuf:"group,5,opt,name=CommitCost" json:"commitcost,omitempty"` 1931 | ApproximateStorageDelta *int32 `protobuf:"varint,8,opt,name=approximate_storage_delta" json:"approximate_storage_delta,omitempty"` 1932 | IdSequenceUpdates *int32 `protobuf:"varint,9,opt,name=id_sequence_updates" json:"id_sequence_updates,omitempty"` 1933 | XXX_unrecognized []byte `json:"-"` 1934 | } 1935 | 1936 | func (m *Cost) Reset() { *m = Cost{} } 1937 | func (m *Cost) String() string { return proto.CompactTextString(m) } 1938 | func (*Cost) ProtoMessage() {} 1939 | 1940 | func (m *Cost) GetIndexWrites() int32 { 1941 | if m != nil && m.IndexWrites != nil { 1942 | return *m.IndexWrites 1943 | } 1944 | return 0 1945 | } 1946 | 1947 | func (m *Cost) GetIndexWriteBytes() int32 { 1948 | if m != nil && m.IndexWriteBytes != nil { 1949 | return *m.IndexWriteBytes 1950 | } 1951 | return 0 1952 | } 1953 | 1954 | func (m *Cost) GetEntityWrites() int32 { 1955 | if m != nil && m.EntityWrites != nil { 1956 | return *m.EntityWrites 1957 | } 1958 | return 0 1959 | } 1960 | 1961 | func (m *Cost) GetEntityWriteBytes() int32 { 1962 | if m != nil && m.EntityWriteBytes != nil { 1963 | return *m.EntityWriteBytes 1964 | } 1965 | return 0 1966 | } 1967 | 1968 | func (m *Cost) GetCommitcost() *Cost_CommitCost { 1969 | if m != nil { 1970 | return m.Commitcost 1971 | } 1972 | return nil 1973 | } 1974 | 1975 | func (m *Cost) GetApproximateStorageDelta() int32 { 1976 | if m != nil && m.ApproximateStorageDelta != nil { 1977 | return *m.ApproximateStorageDelta 1978 | } 1979 | return 0 1980 | } 1981 | 1982 | func (m *Cost) GetIdSequenceUpdates() int32 { 1983 | if m != nil && m.IdSequenceUpdates != nil { 1984 | return *m.IdSequenceUpdates 1985 | } 1986 | return 0 1987 | } 1988 | 1989 | type Cost_CommitCost struct { 1990 | RequestedEntityPuts *int32 `protobuf:"varint,6,opt,name=requested_entity_puts" json:"requested_entity_puts,omitempty"` 1991 | RequestedEntityDeletes *int32 `protobuf:"varint,7,opt,name=requested_entity_deletes" json:"requested_entity_deletes,omitempty"` 1992 | XXX_unrecognized []byte `json:"-"` 1993 | } 1994 | 1995 | func (m *Cost_CommitCost) Reset() { *m = Cost_CommitCost{} } 1996 | func (m *Cost_CommitCost) String() string { return proto.CompactTextString(m) } 1997 | func (*Cost_CommitCost) ProtoMessage() {} 1998 | 1999 | func (m *Cost_CommitCost) GetRequestedEntityPuts() int32 { 2000 | if m != nil && m.RequestedEntityPuts != nil { 2001 | return *m.RequestedEntityPuts 2002 | } 2003 | return 0 2004 | } 2005 | 2006 | func (m *Cost_CommitCost) GetRequestedEntityDeletes() int32 { 2007 | if m != nil && m.RequestedEntityDeletes != nil { 2008 | return *m.RequestedEntityDeletes 2009 | } 2010 | return 0 2011 | } 2012 | 2013 | type GetRequest struct { 2014 | Header *InternalHeader `protobuf:"bytes,6,opt,name=header" json:"header,omitempty"` 2015 | Key []*Reference `protobuf:"bytes,1,rep,name=key" json:"key,omitempty"` 2016 | Transaction *Transaction `protobuf:"bytes,2,opt,name=transaction" json:"transaction,omitempty"` 2017 | FailoverMs *int64 `protobuf:"varint,3,opt,name=failover_ms" json:"failover_ms,omitempty"` 2018 | Strong *bool `protobuf:"varint,4,opt,name=strong" json:"strong,omitempty"` 2019 | AllowDeferred *bool `protobuf:"varint,5,opt,name=allow_deferred,def=0" json:"allow_deferred,omitempty"` 2020 | XXX_unrecognized []byte `json:"-"` 2021 | } 2022 | 2023 | func (m *GetRequest) Reset() { *m = GetRequest{} } 2024 | func (m *GetRequest) String() string { return proto.CompactTextString(m) } 2025 | func (*GetRequest) ProtoMessage() {} 2026 | 2027 | const Default_GetRequest_AllowDeferred bool = false 2028 | 2029 | func (m *GetRequest) GetHeader() *InternalHeader { 2030 | if m != nil { 2031 | return m.Header 2032 | } 2033 | return nil 2034 | } 2035 | 2036 | func (m *GetRequest) GetKey() []*Reference { 2037 | if m != nil { 2038 | return m.Key 2039 | } 2040 | return nil 2041 | } 2042 | 2043 | func (m *GetRequest) GetTransaction() *Transaction { 2044 | if m != nil { 2045 | return m.Transaction 2046 | } 2047 | return nil 2048 | } 2049 | 2050 | func (m *GetRequest) GetFailoverMs() int64 { 2051 | if m != nil && m.FailoverMs != nil { 2052 | return *m.FailoverMs 2053 | } 2054 | return 0 2055 | } 2056 | 2057 | func (m *GetRequest) GetStrong() bool { 2058 | if m != nil && m.Strong != nil { 2059 | return *m.Strong 2060 | } 2061 | return false 2062 | } 2063 | 2064 | func (m *GetRequest) GetAllowDeferred() bool { 2065 | if m != nil && m.AllowDeferred != nil { 2066 | return *m.AllowDeferred 2067 | } 2068 | return Default_GetRequest_AllowDeferred 2069 | } 2070 | 2071 | type GetResponse struct { 2072 | Entity []*GetResponse_Entity `protobuf:"group,1,rep,name=Entity" json:"entity,omitempty"` 2073 | Deferred []*Reference `protobuf:"bytes,5,rep,name=deferred" json:"deferred,omitempty"` 2074 | InOrder *bool `protobuf:"varint,6,opt,name=in_order,def=1" json:"in_order,omitempty"` 2075 | XXX_unrecognized []byte `json:"-"` 2076 | } 2077 | 2078 | func (m *GetResponse) Reset() { *m = GetResponse{} } 2079 | func (m *GetResponse) String() string { return proto.CompactTextString(m) } 2080 | func (*GetResponse) ProtoMessage() {} 2081 | 2082 | const Default_GetResponse_InOrder bool = true 2083 | 2084 | func (m *GetResponse) GetEntity() []*GetResponse_Entity { 2085 | if m != nil { 2086 | return m.Entity 2087 | } 2088 | return nil 2089 | } 2090 | 2091 | func (m *GetResponse) GetDeferred() []*Reference { 2092 | if m != nil { 2093 | return m.Deferred 2094 | } 2095 | return nil 2096 | } 2097 | 2098 | func (m *GetResponse) GetInOrder() bool { 2099 | if m != nil && m.InOrder != nil { 2100 | return *m.InOrder 2101 | } 2102 | return Default_GetResponse_InOrder 2103 | } 2104 | 2105 | type GetResponse_Entity struct { 2106 | Entity *EntityProto `protobuf:"bytes,2,opt,name=entity" json:"entity,omitempty"` 2107 | Key *Reference `protobuf:"bytes,4,opt,name=key" json:"key,omitempty"` 2108 | Version *int64 `protobuf:"varint,3,opt,name=version" json:"version,omitempty"` 2109 | XXX_unrecognized []byte `json:"-"` 2110 | } 2111 | 2112 | func (m *GetResponse_Entity) Reset() { *m = GetResponse_Entity{} } 2113 | func (m *GetResponse_Entity) String() string { return proto.CompactTextString(m) } 2114 | func (*GetResponse_Entity) ProtoMessage() {} 2115 | 2116 | func (m *GetResponse_Entity) GetEntity() *EntityProto { 2117 | if m != nil { 2118 | return m.Entity 2119 | } 2120 | return nil 2121 | } 2122 | 2123 | func (m *GetResponse_Entity) GetKey() *Reference { 2124 | if m != nil { 2125 | return m.Key 2126 | } 2127 | return nil 2128 | } 2129 | 2130 | func (m *GetResponse_Entity) GetVersion() int64 { 2131 | if m != nil && m.Version != nil { 2132 | return *m.Version 2133 | } 2134 | return 0 2135 | } 2136 | 2137 | type PutRequest struct { 2138 | Header *InternalHeader `protobuf:"bytes,11,opt,name=header" json:"header,omitempty"` 2139 | Entity []*EntityProto `protobuf:"bytes,1,rep,name=entity" json:"entity,omitempty"` 2140 | Transaction *Transaction `protobuf:"bytes,2,opt,name=transaction" json:"transaction,omitempty"` 2141 | CompositeIndex []*CompositeIndex `protobuf:"bytes,3,rep,name=composite_index" json:"composite_index,omitempty"` 2142 | Trusted *bool `protobuf:"varint,4,opt,name=trusted,def=0" json:"trusted,omitempty"` 2143 | Force *bool `protobuf:"varint,7,opt,name=force,def=0" json:"force,omitempty"` 2144 | MarkChanges *bool `protobuf:"varint,8,opt,name=mark_changes,def=0" json:"mark_changes,omitempty"` 2145 | Snapshot []*Snapshot `protobuf:"bytes,9,rep,name=snapshot" json:"snapshot,omitempty"` 2146 | AutoIdPolicy *PutRequest_AutoIdPolicy `protobuf:"varint,10,opt,name=auto_id_policy,enum=appengine.PutRequest_AutoIdPolicy,def=0" json:"auto_id_policy,omitempty"` 2147 | XXX_unrecognized []byte `json:"-"` 2148 | } 2149 | 2150 | func (m *PutRequest) Reset() { *m = PutRequest{} } 2151 | func (m *PutRequest) String() string { return proto.CompactTextString(m) } 2152 | func (*PutRequest) ProtoMessage() {} 2153 | 2154 | const Default_PutRequest_Trusted bool = false 2155 | const Default_PutRequest_Force bool = false 2156 | const Default_PutRequest_MarkChanges bool = false 2157 | const Default_PutRequest_AutoIdPolicy PutRequest_AutoIdPolicy = PutRequest_CURRENT 2158 | 2159 | func (m *PutRequest) GetHeader() *InternalHeader { 2160 | if m != nil { 2161 | return m.Header 2162 | } 2163 | return nil 2164 | } 2165 | 2166 | func (m *PutRequest) GetEntity() []*EntityProto { 2167 | if m != nil { 2168 | return m.Entity 2169 | } 2170 | return nil 2171 | } 2172 | 2173 | func (m *PutRequest) GetTransaction() *Transaction { 2174 | if m != nil { 2175 | return m.Transaction 2176 | } 2177 | return nil 2178 | } 2179 | 2180 | func (m *PutRequest) GetCompositeIndex() []*CompositeIndex { 2181 | if m != nil { 2182 | return m.CompositeIndex 2183 | } 2184 | return nil 2185 | } 2186 | 2187 | func (m *PutRequest) GetTrusted() bool { 2188 | if m != nil && m.Trusted != nil { 2189 | return *m.Trusted 2190 | } 2191 | return Default_PutRequest_Trusted 2192 | } 2193 | 2194 | func (m *PutRequest) GetForce() bool { 2195 | if m != nil && m.Force != nil { 2196 | return *m.Force 2197 | } 2198 | return Default_PutRequest_Force 2199 | } 2200 | 2201 | func (m *PutRequest) GetMarkChanges() bool { 2202 | if m != nil && m.MarkChanges != nil { 2203 | return *m.MarkChanges 2204 | } 2205 | return Default_PutRequest_MarkChanges 2206 | } 2207 | 2208 | func (m *PutRequest) GetSnapshot() []*Snapshot { 2209 | if m != nil { 2210 | return m.Snapshot 2211 | } 2212 | return nil 2213 | } 2214 | 2215 | func (m *PutRequest) GetAutoIdPolicy() PutRequest_AutoIdPolicy { 2216 | if m != nil && m.AutoIdPolicy != nil { 2217 | return *m.AutoIdPolicy 2218 | } 2219 | return Default_PutRequest_AutoIdPolicy 2220 | } 2221 | 2222 | type PutResponse struct { 2223 | Key []*Reference `protobuf:"bytes,1,rep,name=key" json:"key,omitempty"` 2224 | Cost *Cost `protobuf:"bytes,2,opt,name=cost" json:"cost,omitempty"` 2225 | Version []int64 `protobuf:"varint,3,rep,name=version" json:"version,omitempty"` 2226 | XXX_unrecognized []byte `json:"-"` 2227 | } 2228 | 2229 | func (m *PutResponse) Reset() { *m = PutResponse{} } 2230 | func (m *PutResponse) String() string { return proto.CompactTextString(m) } 2231 | func (*PutResponse) ProtoMessage() {} 2232 | 2233 | func (m *PutResponse) GetKey() []*Reference { 2234 | if m != nil { 2235 | return m.Key 2236 | } 2237 | return nil 2238 | } 2239 | 2240 | func (m *PutResponse) GetCost() *Cost { 2241 | if m != nil { 2242 | return m.Cost 2243 | } 2244 | return nil 2245 | } 2246 | 2247 | func (m *PutResponse) GetVersion() []int64 { 2248 | if m != nil { 2249 | return m.Version 2250 | } 2251 | return nil 2252 | } 2253 | 2254 | type TouchRequest struct { 2255 | Header *InternalHeader `protobuf:"bytes,10,opt,name=header" json:"header,omitempty"` 2256 | Key []*Reference `protobuf:"bytes,1,rep,name=key" json:"key,omitempty"` 2257 | CompositeIndex []*CompositeIndex `protobuf:"bytes,2,rep,name=composite_index" json:"composite_index,omitempty"` 2258 | Force *bool `protobuf:"varint,3,opt,name=force,def=0" json:"force,omitempty"` 2259 | Snapshot []*Snapshot `protobuf:"bytes,9,rep,name=snapshot" json:"snapshot,omitempty"` 2260 | XXX_unrecognized []byte `json:"-"` 2261 | } 2262 | 2263 | func (m *TouchRequest) Reset() { *m = TouchRequest{} } 2264 | func (m *TouchRequest) String() string { return proto.CompactTextString(m) } 2265 | func (*TouchRequest) ProtoMessage() {} 2266 | 2267 | const Default_TouchRequest_Force bool = false 2268 | 2269 | func (m *TouchRequest) GetHeader() *InternalHeader { 2270 | if m != nil { 2271 | return m.Header 2272 | } 2273 | return nil 2274 | } 2275 | 2276 | func (m *TouchRequest) GetKey() []*Reference { 2277 | if m != nil { 2278 | return m.Key 2279 | } 2280 | return nil 2281 | } 2282 | 2283 | func (m *TouchRequest) GetCompositeIndex() []*CompositeIndex { 2284 | if m != nil { 2285 | return m.CompositeIndex 2286 | } 2287 | return nil 2288 | } 2289 | 2290 | func (m *TouchRequest) GetForce() bool { 2291 | if m != nil && m.Force != nil { 2292 | return *m.Force 2293 | } 2294 | return Default_TouchRequest_Force 2295 | } 2296 | 2297 | func (m *TouchRequest) GetSnapshot() []*Snapshot { 2298 | if m != nil { 2299 | return m.Snapshot 2300 | } 2301 | return nil 2302 | } 2303 | 2304 | type TouchResponse struct { 2305 | Cost *Cost `protobuf:"bytes,1,opt,name=cost" json:"cost,omitempty"` 2306 | XXX_unrecognized []byte `json:"-"` 2307 | } 2308 | 2309 | func (m *TouchResponse) Reset() { *m = TouchResponse{} } 2310 | func (m *TouchResponse) String() string { return proto.CompactTextString(m) } 2311 | func (*TouchResponse) ProtoMessage() {} 2312 | 2313 | func (m *TouchResponse) GetCost() *Cost { 2314 | if m != nil { 2315 | return m.Cost 2316 | } 2317 | return nil 2318 | } 2319 | 2320 | type DeleteRequest struct { 2321 | Header *InternalHeader `protobuf:"bytes,10,opt,name=header" json:"header,omitempty"` 2322 | Key []*Reference `protobuf:"bytes,6,rep,name=key" json:"key,omitempty"` 2323 | Transaction *Transaction `protobuf:"bytes,5,opt,name=transaction" json:"transaction,omitempty"` 2324 | Trusted *bool `protobuf:"varint,4,opt,name=trusted,def=0" json:"trusted,omitempty"` 2325 | Force *bool `protobuf:"varint,7,opt,name=force,def=0" json:"force,omitempty"` 2326 | MarkChanges *bool `protobuf:"varint,8,opt,name=mark_changes,def=0" json:"mark_changes,omitempty"` 2327 | Snapshot []*Snapshot `protobuf:"bytes,9,rep,name=snapshot" json:"snapshot,omitempty"` 2328 | XXX_unrecognized []byte `json:"-"` 2329 | } 2330 | 2331 | func (m *DeleteRequest) Reset() { *m = DeleteRequest{} } 2332 | func (m *DeleteRequest) String() string { return proto.CompactTextString(m) } 2333 | func (*DeleteRequest) ProtoMessage() {} 2334 | 2335 | const Default_DeleteRequest_Trusted bool = false 2336 | const Default_DeleteRequest_Force bool = false 2337 | const Default_DeleteRequest_MarkChanges bool = false 2338 | 2339 | func (m *DeleteRequest) GetHeader() *InternalHeader { 2340 | if m != nil { 2341 | return m.Header 2342 | } 2343 | return nil 2344 | } 2345 | 2346 | func (m *DeleteRequest) GetKey() []*Reference { 2347 | if m != nil { 2348 | return m.Key 2349 | } 2350 | return nil 2351 | } 2352 | 2353 | func (m *DeleteRequest) GetTransaction() *Transaction { 2354 | if m != nil { 2355 | return m.Transaction 2356 | } 2357 | return nil 2358 | } 2359 | 2360 | func (m *DeleteRequest) GetTrusted() bool { 2361 | if m != nil && m.Trusted != nil { 2362 | return *m.Trusted 2363 | } 2364 | return Default_DeleteRequest_Trusted 2365 | } 2366 | 2367 | func (m *DeleteRequest) GetForce() bool { 2368 | if m != nil && m.Force != nil { 2369 | return *m.Force 2370 | } 2371 | return Default_DeleteRequest_Force 2372 | } 2373 | 2374 | func (m *DeleteRequest) GetMarkChanges() bool { 2375 | if m != nil && m.MarkChanges != nil { 2376 | return *m.MarkChanges 2377 | } 2378 | return Default_DeleteRequest_MarkChanges 2379 | } 2380 | 2381 | func (m *DeleteRequest) GetSnapshot() []*Snapshot { 2382 | if m != nil { 2383 | return m.Snapshot 2384 | } 2385 | return nil 2386 | } 2387 | 2388 | type DeleteResponse struct { 2389 | Cost *Cost `protobuf:"bytes,1,opt,name=cost" json:"cost,omitempty"` 2390 | Version []int64 `protobuf:"varint,3,rep,name=version" json:"version,omitempty"` 2391 | XXX_unrecognized []byte `json:"-"` 2392 | } 2393 | 2394 | func (m *DeleteResponse) Reset() { *m = DeleteResponse{} } 2395 | func (m *DeleteResponse) String() string { return proto.CompactTextString(m) } 2396 | func (*DeleteResponse) ProtoMessage() {} 2397 | 2398 | func (m *DeleteResponse) GetCost() *Cost { 2399 | if m != nil { 2400 | return m.Cost 2401 | } 2402 | return nil 2403 | } 2404 | 2405 | func (m *DeleteResponse) GetVersion() []int64 { 2406 | if m != nil { 2407 | return m.Version 2408 | } 2409 | return nil 2410 | } 2411 | 2412 | type NextRequest struct { 2413 | Header *InternalHeader `protobuf:"bytes,5,opt,name=header" json:"header,omitempty"` 2414 | Cursor *Cursor `protobuf:"bytes,1,req,name=cursor" json:"cursor,omitempty"` 2415 | Count *int32 `protobuf:"varint,2,opt,name=count" json:"count,omitempty"` 2416 | Offset *int32 `protobuf:"varint,4,opt,name=offset,def=0" json:"offset,omitempty"` 2417 | Compile *bool `protobuf:"varint,3,opt,name=compile,def=0" json:"compile,omitempty"` 2418 | XXX_unrecognized []byte `json:"-"` 2419 | } 2420 | 2421 | func (m *NextRequest) Reset() { *m = NextRequest{} } 2422 | func (m *NextRequest) String() string { return proto.CompactTextString(m) } 2423 | func (*NextRequest) ProtoMessage() {} 2424 | 2425 | const Default_NextRequest_Offset int32 = 0 2426 | const Default_NextRequest_Compile bool = false 2427 | 2428 | func (m *NextRequest) GetHeader() *InternalHeader { 2429 | if m != nil { 2430 | return m.Header 2431 | } 2432 | return nil 2433 | } 2434 | 2435 | func (m *NextRequest) GetCursor() *Cursor { 2436 | if m != nil { 2437 | return m.Cursor 2438 | } 2439 | return nil 2440 | } 2441 | 2442 | func (m *NextRequest) GetCount() int32 { 2443 | if m != nil && m.Count != nil { 2444 | return *m.Count 2445 | } 2446 | return 0 2447 | } 2448 | 2449 | func (m *NextRequest) GetOffset() int32 { 2450 | if m != nil && m.Offset != nil { 2451 | return *m.Offset 2452 | } 2453 | return Default_NextRequest_Offset 2454 | } 2455 | 2456 | func (m *NextRequest) GetCompile() bool { 2457 | if m != nil && m.Compile != nil { 2458 | return *m.Compile 2459 | } 2460 | return Default_NextRequest_Compile 2461 | } 2462 | 2463 | type QueryResult struct { 2464 | Cursor *Cursor `protobuf:"bytes,1,opt,name=cursor" json:"cursor,omitempty"` 2465 | Result []*EntityProto `protobuf:"bytes,2,rep,name=result" json:"result,omitempty"` 2466 | SkippedResults *int32 `protobuf:"varint,7,opt,name=skipped_results" json:"skipped_results,omitempty"` 2467 | MoreResults *bool `protobuf:"varint,3,req,name=more_results" json:"more_results,omitempty"` 2468 | KeysOnly *bool `protobuf:"varint,4,opt,name=keys_only" json:"keys_only,omitempty"` 2469 | IndexOnly *bool `protobuf:"varint,9,opt,name=index_only" json:"index_only,omitempty"` 2470 | SmallOps *bool `protobuf:"varint,10,opt,name=small_ops" json:"small_ops,omitempty"` 2471 | CompiledQuery *CompiledQuery `protobuf:"bytes,5,opt,name=compiled_query" json:"compiled_query,omitempty"` 2472 | CompiledCursor *CompiledCursor `protobuf:"bytes,6,opt,name=compiled_cursor" json:"compiled_cursor,omitempty"` 2473 | Index []*CompositeIndex `protobuf:"bytes,8,rep,name=index" json:"index,omitempty"` 2474 | Version []int64 `protobuf:"varint,11,rep,name=version" json:"version,omitempty"` 2475 | XXX_unrecognized []byte `json:"-"` 2476 | } 2477 | 2478 | func (m *QueryResult) Reset() { *m = QueryResult{} } 2479 | func (m *QueryResult) String() string { return proto.CompactTextString(m) } 2480 | func (*QueryResult) ProtoMessage() {} 2481 | 2482 | func (m *QueryResult) GetCursor() *Cursor { 2483 | if m != nil { 2484 | return m.Cursor 2485 | } 2486 | return nil 2487 | } 2488 | 2489 | func (m *QueryResult) GetResult() []*EntityProto { 2490 | if m != nil { 2491 | return m.Result 2492 | } 2493 | return nil 2494 | } 2495 | 2496 | func (m *QueryResult) GetSkippedResults() int32 { 2497 | if m != nil && m.SkippedResults != nil { 2498 | return *m.SkippedResults 2499 | } 2500 | return 0 2501 | } 2502 | 2503 | func (m *QueryResult) GetMoreResults() bool { 2504 | if m != nil && m.MoreResults != nil { 2505 | return *m.MoreResults 2506 | } 2507 | return false 2508 | } 2509 | 2510 | func (m *QueryResult) GetKeysOnly() bool { 2511 | if m != nil && m.KeysOnly != nil { 2512 | return *m.KeysOnly 2513 | } 2514 | return false 2515 | } 2516 | 2517 | func (m *QueryResult) GetIndexOnly() bool { 2518 | if m != nil && m.IndexOnly != nil { 2519 | return *m.IndexOnly 2520 | } 2521 | return false 2522 | } 2523 | 2524 | func (m *QueryResult) GetSmallOps() bool { 2525 | if m != nil && m.SmallOps != nil { 2526 | return *m.SmallOps 2527 | } 2528 | return false 2529 | } 2530 | 2531 | func (m *QueryResult) GetCompiledQuery() *CompiledQuery { 2532 | if m != nil { 2533 | return m.CompiledQuery 2534 | } 2535 | return nil 2536 | } 2537 | 2538 | func (m *QueryResult) GetCompiledCursor() *CompiledCursor { 2539 | if m != nil { 2540 | return m.CompiledCursor 2541 | } 2542 | return nil 2543 | } 2544 | 2545 | func (m *QueryResult) GetIndex() []*CompositeIndex { 2546 | if m != nil { 2547 | return m.Index 2548 | } 2549 | return nil 2550 | } 2551 | 2552 | func (m *QueryResult) GetVersion() []int64 { 2553 | if m != nil { 2554 | return m.Version 2555 | } 2556 | return nil 2557 | } 2558 | 2559 | type AllocateIdsRequest struct { 2560 | Header *InternalHeader `protobuf:"bytes,4,opt,name=header" json:"header,omitempty"` 2561 | ModelKey *Reference `protobuf:"bytes,1,opt,name=model_key" json:"model_key,omitempty"` 2562 | Size *int64 `protobuf:"varint,2,opt,name=size" json:"size,omitempty"` 2563 | Max *int64 `protobuf:"varint,3,opt,name=max" json:"max,omitempty"` 2564 | Reserve []*Reference `protobuf:"bytes,5,rep,name=reserve" json:"reserve,omitempty"` 2565 | XXX_unrecognized []byte `json:"-"` 2566 | } 2567 | 2568 | func (m *AllocateIdsRequest) Reset() { *m = AllocateIdsRequest{} } 2569 | func (m *AllocateIdsRequest) String() string { return proto.CompactTextString(m) } 2570 | func (*AllocateIdsRequest) ProtoMessage() {} 2571 | 2572 | func (m *AllocateIdsRequest) GetHeader() *InternalHeader { 2573 | if m != nil { 2574 | return m.Header 2575 | } 2576 | return nil 2577 | } 2578 | 2579 | func (m *AllocateIdsRequest) GetModelKey() *Reference { 2580 | if m != nil { 2581 | return m.ModelKey 2582 | } 2583 | return nil 2584 | } 2585 | 2586 | func (m *AllocateIdsRequest) GetSize() int64 { 2587 | if m != nil && m.Size != nil { 2588 | return *m.Size 2589 | } 2590 | return 0 2591 | } 2592 | 2593 | func (m *AllocateIdsRequest) GetMax() int64 { 2594 | if m != nil && m.Max != nil { 2595 | return *m.Max 2596 | } 2597 | return 0 2598 | } 2599 | 2600 | func (m *AllocateIdsRequest) GetReserve() []*Reference { 2601 | if m != nil { 2602 | return m.Reserve 2603 | } 2604 | return nil 2605 | } 2606 | 2607 | type AllocateIdsResponse struct { 2608 | Start *int64 `protobuf:"varint,1,req,name=start" json:"start,omitempty"` 2609 | End *int64 `protobuf:"varint,2,req,name=end" json:"end,omitempty"` 2610 | Cost *Cost `protobuf:"bytes,3,opt,name=cost" json:"cost,omitempty"` 2611 | XXX_unrecognized []byte `json:"-"` 2612 | } 2613 | 2614 | func (m *AllocateIdsResponse) Reset() { *m = AllocateIdsResponse{} } 2615 | func (m *AllocateIdsResponse) String() string { return proto.CompactTextString(m) } 2616 | func (*AllocateIdsResponse) ProtoMessage() {} 2617 | 2618 | func (m *AllocateIdsResponse) GetStart() int64 { 2619 | if m != nil && m.Start != nil { 2620 | return *m.Start 2621 | } 2622 | return 0 2623 | } 2624 | 2625 | func (m *AllocateIdsResponse) GetEnd() int64 { 2626 | if m != nil && m.End != nil { 2627 | return *m.End 2628 | } 2629 | return 0 2630 | } 2631 | 2632 | func (m *AllocateIdsResponse) GetCost() *Cost { 2633 | if m != nil { 2634 | return m.Cost 2635 | } 2636 | return nil 2637 | } 2638 | 2639 | type CompositeIndices struct { 2640 | Index []*CompositeIndex `protobuf:"bytes,1,rep,name=index" json:"index,omitempty"` 2641 | XXX_unrecognized []byte `json:"-"` 2642 | } 2643 | 2644 | func (m *CompositeIndices) Reset() { *m = CompositeIndices{} } 2645 | func (m *CompositeIndices) String() string { return proto.CompactTextString(m) } 2646 | func (*CompositeIndices) ProtoMessage() {} 2647 | 2648 | func (m *CompositeIndices) GetIndex() []*CompositeIndex { 2649 | if m != nil { 2650 | return m.Index 2651 | } 2652 | return nil 2653 | } 2654 | 2655 | type AddActionsRequest struct { 2656 | Header *InternalHeader `protobuf:"bytes,3,opt,name=header" json:"header,omitempty"` 2657 | Transaction *Transaction `protobuf:"bytes,1,req,name=transaction" json:"transaction,omitempty"` 2658 | Action []*Action `protobuf:"bytes,2,rep,name=action" json:"action,omitempty"` 2659 | XXX_unrecognized []byte `json:"-"` 2660 | } 2661 | 2662 | func (m *AddActionsRequest) Reset() { *m = AddActionsRequest{} } 2663 | func (m *AddActionsRequest) String() string { return proto.CompactTextString(m) } 2664 | func (*AddActionsRequest) ProtoMessage() {} 2665 | 2666 | func (m *AddActionsRequest) GetHeader() *InternalHeader { 2667 | if m != nil { 2668 | return m.Header 2669 | } 2670 | return nil 2671 | } 2672 | 2673 | func (m *AddActionsRequest) GetTransaction() *Transaction { 2674 | if m != nil { 2675 | return m.Transaction 2676 | } 2677 | return nil 2678 | } 2679 | 2680 | func (m *AddActionsRequest) GetAction() []*Action { 2681 | if m != nil { 2682 | return m.Action 2683 | } 2684 | return nil 2685 | } 2686 | 2687 | type AddActionsResponse struct { 2688 | XXX_unrecognized []byte `json:"-"` 2689 | } 2690 | 2691 | func (m *AddActionsResponse) Reset() { *m = AddActionsResponse{} } 2692 | func (m *AddActionsResponse) String() string { return proto.CompactTextString(m) } 2693 | func (*AddActionsResponse) ProtoMessage() {} 2694 | 2695 | type BeginTransactionRequest struct { 2696 | Header *InternalHeader `protobuf:"bytes,3,opt,name=header" json:"header,omitempty"` 2697 | App *string `protobuf:"bytes,1,req,name=app" json:"app,omitempty"` 2698 | AllowMultipleEg *bool `protobuf:"varint,2,opt,name=allow_multiple_eg,def=0" json:"allow_multiple_eg,omitempty"` 2699 | XXX_unrecognized []byte `json:"-"` 2700 | } 2701 | 2702 | func (m *BeginTransactionRequest) Reset() { *m = BeginTransactionRequest{} } 2703 | func (m *BeginTransactionRequest) String() string { return proto.CompactTextString(m) } 2704 | func (*BeginTransactionRequest) ProtoMessage() {} 2705 | 2706 | const Default_BeginTransactionRequest_AllowMultipleEg bool = false 2707 | 2708 | func (m *BeginTransactionRequest) GetHeader() *InternalHeader { 2709 | if m != nil { 2710 | return m.Header 2711 | } 2712 | return nil 2713 | } 2714 | 2715 | func (m *BeginTransactionRequest) GetApp() string { 2716 | if m != nil && m.App != nil { 2717 | return *m.App 2718 | } 2719 | return "" 2720 | } 2721 | 2722 | func (m *BeginTransactionRequest) GetAllowMultipleEg() bool { 2723 | if m != nil && m.AllowMultipleEg != nil { 2724 | return *m.AllowMultipleEg 2725 | } 2726 | return Default_BeginTransactionRequest_AllowMultipleEg 2727 | } 2728 | 2729 | type CommitResponse struct { 2730 | Cost *Cost `protobuf:"bytes,1,opt,name=cost" json:"cost,omitempty"` 2731 | Version []*CommitResponse_Version `protobuf:"group,3,rep,name=Version" json:"version,omitempty"` 2732 | XXX_unrecognized []byte `json:"-"` 2733 | } 2734 | 2735 | func (m *CommitResponse) Reset() { *m = CommitResponse{} } 2736 | func (m *CommitResponse) String() string { return proto.CompactTextString(m) } 2737 | func (*CommitResponse) ProtoMessage() {} 2738 | 2739 | func (m *CommitResponse) GetCost() *Cost { 2740 | if m != nil { 2741 | return m.Cost 2742 | } 2743 | return nil 2744 | } 2745 | 2746 | func (m *CommitResponse) GetVersion() []*CommitResponse_Version { 2747 | if m != nil { 2748 | return m.Version 2749 | } 2750 | return nil 2751 | } 2752 | 2753 | type CommitResponse_Version struct { 2754 | RootEntityKey *Reference `protobuf:"bytes,4,req,name=root_entity_key" json:"root_entity_key,omitempty"` 2755 | Version *int64 `protobuf:"varint,5,req,name=version" json:"version,omitempty"` 2756 | XXX_unrecognized []byte `json:"-"` 2757 | } 2758 | 2759 | func (m *CommitResponse_Version) Reset() { *m = CommitResponse_Version{} } 2760 | func (m *CommitResponse_Version) String() string { return proto.CompactTextString(m) } 2761 | func (*CommitResponse_Version) ProtoMessage() {} 2762 | 2763 | func (m *CommitResponse_Version) GetRootEntityKey() *Reference { 2764 | if m != nil { 2765 | return m.RootEntityKey 2766 | } 2767 | return nil 2768 | } 2769 | 2770 | func (m *CommitResponse_Version) GetVersion() int64 { 2771 | if m != nil && m.Version != nil { 2772 | return *m.Version 2773 | } 2774 | return 0 2775 | } 2776 | 2777 | func init() { 2778 | } 2779 | -------------------------------------------------------------------------------- /backup/pb/datastore_v3.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | option go_package = "datastore"; 3 | 4 | package appengine; 5 | 6 | message Action{} 7 | 8 | message PropertyValue { 9 | optional int64 int64Value = 1; 10 | optional bool booleanValue = 2; 11 | optional string stringValue = 3; 12 | optional double doubleValue = 4; 13 | 14 | optional group PointValue = 5 { 15 | required double x = 6; 16 | required double y = 7; 17 | } 18 | 19 | optional group UserValue = 8 { 20 | required string email = 9; 21 | required string auth_domain = 10; 22 | optional string nickname = 11; 23 | optional string federated_identity = 21; 24 | optional string federated_provider = 22; 25 | } 26 | 27 | optional group ReferenceValue = 12 { 28 | required string app = 13; 29 | optional string name_space = 20; 30 | repeated group PathElement = 14 { 31 | required string type = 15; 32 | optional int64 id = 16; 33 | optional string name = 17; 34 | } 35 | } 36 | } 37 | 38 | message Property { 39 | enum Meaning { 40 | NO_MEANING = 0; 41 | BLOB = 14; 42 | TEXT = 15; 43 | BYTESTRING = 16; 44 | 45 | ATOM_CATEGORY = 1; 46 | ATOM_LINK = 2; 47 | ATOM_TITLE = 3; 48 | ATOM_CONTENT = 4; 49 | ATOM_SUMMARY = 5; 50 | ATOM_AUTHOR = 6; 51 | 52 | GD_WHEN = 7; 53 | GD_EMAIL = 8; 54 | GEORSS_POINT = 9; 55 | GD_IM = 10; 56 | 57 | GD_PHONENUMBER = 11; 58 | GD_POSTALADDRESS = 12; 59 | 60 | GD_RATING = 13; 61 | 62 | BLOBKEY = 17; 63 | ENTITY_PROTO = 19; 64 | 65 | INDEX_VALUE = 18; 66 | }; 67 | 68 | optional Meaning meaning = 1 [default = NO_MEANING]; 69 | optional string meaning_uri = 2; 70 | 71 | required string name = 3; 72 | 73 | required PropertyValue value = 5; 74 | 75 | required bool multiple = 4; 76 | 77 | optional bool searchable = 6 [default=false]; 78 | 79 | enum FtsTokenizationOption { 80 | HTML = 1; 81 | ATOM = 2; 82 | } 83 | 84 | optional FtsTokenizationOption fts_tokenization_option = 8; 85 | 86 | optional string locale = 9 [default = "en"]; 87 | } 88 | 89 | message Path { 90 | repeated group Element = 1 { 91 | required string type = 2; 92 | optional int64 id = 3; 93 | optional string name = 4; 94 | } 95 | } 96 | 97 | message Reference { 98 | required string app = 13; 99 | optional string name_space = 20; 100 | required Path path = 14; 101 | } 102 | 103 | message User { 104 | required string email = 1; 105 | required string auth_domain = 2; 106 | optional string nickname = 3; 107 | optional string federated_identity = 6; 108 | optional string federated_provider = 7; 109 | } 110 | 111 | message EntityProto { 112 | required Reference key = 13; 113 | required Path entity_group = 16; 114 | optional User owner = 17; 115 | 116 | enum Kind { 117 | GD_CONTACT = 1; 118 | GD_EVENT = 2; 119 | GD_MESSAGE = 3; 120 | } 121 | optional Kind kind = 4; 122 | optional string kind_uri = 5; 123 | 124 | repeated Property property = 14; 125 | repeated Property raw_property = 15; 126 | 127 | optional int32 rank = 18; 128 | } 129 | 130 | message CompositeProperty { 131 | required int64 index_id = 1; 132 | repeated string value = 2; 133 | } 134 | 135 | message Index { 136 | required string entity_type = 1; 137 | required bool ancestor = 5; 138 | repeated group Property = 2 { 139 | required string name = 3; 140 | enum Direction { 141 | ASCENDING = 1; 142 | DESCENDING = 2; 143 | } 144 | optional Direction direction = 4 [default = ASCENDING]; 145 | } 146 | } 147 | 148 | message CompositeIndex { 149 | required string app_id = 1; 150 | required int64 id = 2; 151 | required Index definition = 3; 152 | 153 | enum State { 154 | WRITE_ONLY = 1; 155 | READ_WRITE = 2; 156 | DELETED = 3; 157 | ERROR = 4; 158 | } 159 | required State state = 4; 160 | 161 | optional bool only_use_if_required = 6 [default = false]; 162 | } 163 | 164 | message IndexPostfix { 165 | message IndexValue { 166 | required string property_name = 1; 167 | required PropertyValue value = 2; 168 | } 169 | 170 | repeated IndexValue index_value = 1; 171 | 172 | optional Reference key = 2; 173 | 174 | optional bool before = 3 [default=true]; 175 | } 176 | 177 | message IndexPosition { 178 | optional string key = 1; 179 | 180 | optional bool before = 2 [default=true]; 181 | } 182 | 183 | message Snapshot { 184 | enum Status { 185 | INACTIVE = 0; 186 | ACTIVE = 1; 187 | } 188 | 189 | required int64 ts = 1; 190 | } 191 | 192 | message InternalHeader { 193 | optional string qos = 1; 194 | } 195 | 196 | message Transaction { 197 | optional InternalHeader header = 4; 198 | required fixed64 handle = 1; 199 | required string app = 2; 200 | optional bool mark_changes = 3 [default = false]; 201 | } 202 | 203 | message Query { 204 | optional InternalHeader header = 39; 205 | 206 | required string app = 1; 207 | optional string name_space = 29; 208 | 209 | optional string kind = 3; 210 | optional Reference ancestor = 17; 211 | 212 | repeated group Filter = 4 { 213 | enum Operator { 214 | LESS_THAN = 1; 215 | LESS_THAN_OR_EQUAL = 2; 216 | GREATER_THAN = 3; 217 | GREATER_THAN_OR_EQUAL = 4; 218 | EQUAL = 5; 219 | IN = 6; 220 | EXISTS = 7; 221 | } 222 | 223 | required Operator op = 6; 224 | repeated Property property = 14; 225 | } 226 | 227 | optional string search_query = 8; 228 | 229 | repeated group Order = 9 { 230 | enum Direction { 231 | ASCENDING = 1; 232 | DESCENDING = 2; 233 | } 234 | 235 | required string property = 10; 236 | optional Direction direction = 11 [default = ASCENDING]; 237 | } 238 | 239 | enum Hint { 240 | ORDER_FIRST = 1; 241 | ANCESTOR_FIRST = 2; 242 | FILTER_FIRST = 3; 243 | } 244 | optional Hint hint = 18; 245 | 246 | optional int32 count = 23; 247 | 248 | optional int32 offset = 12 [default = 0]; 249 | 250 | optional int32 limit = 16; 251 | 252 | optional CompiledCursor compiled_cursor = 30; 253 | optional CompiledCursor end_compiled_cursor = 31; 254 | 255 | repeated CompositeIndex composite_index = 19; 256 | 257 | optional bool require_perfect_plan = 20 [default = false]; 258 | 259 | optional bool keys_only = 21 [default = false]; 260 | 261 | optional Transaction transaction = 22; 262 | 263 | optional bool compile = 25 [default = false]; 264 | 265 | optional int64 failover_ms = 26; 266 | 267 | optional bool strong = 32; 268 | 269 | repeated string property_name = 33; 270 | 271 | repeated string group_by_property_name = 34; 272 | 273 | optional bool distinct = 24; 274 | 275 | optional int64 min_safe_time_seconds = 35; 276 | 277 | repeated string safe_replica_name = 36; 278 | 279 | optional bool persist_offset = 37 [default=false]; 280 | } 281 | 282 | message CompiledQuery { 283 | required group PrimaryScan = 1 { 284 | optional string index_name = 2; 285 | 286 | optional string start_key = 3; 287 | optional bool start_inclusive = 4; 288 | optional string end_key = 5; 289 | optional bool end_inclusive = 6; 290 | 291 | repeated string start_postfix_value = 22; 292 | repeated string end_postfix_value = 23; 293 | 294 | optional int64 end_unapplied_log_timestamp_us = 19; 295 | } 296 | 297 | repeated group MergeJoinScan = 7 { 298 | required string index_name = 8; 299 | 300 | repeated string prefix_value = 9; 301 | 302 | optional bool value_prefix = 20 [default=false]; 303 | } 304 | 305 | optional Index index_def = 21; 306 | 307 | optional int32 offset = 10 [default = 0]; 308 | 309 | optional int32 limit = 11; 310 | 311 | required bool keys_only = 12; 312 | 313 | repeated string property_name = 24; 314 | 315 | optional int32 distinct_infix_size = 25; 316 | 317 | optional group EntityFilter = 13 { 318 | optional bool distinct = 14 [default=false]; 319 | 320 | optional string kind = 17; 321 | optional Reference ancestor = 18; 322 | } 323 | } 324 | 325 | message CompiledCursor { 326 | optional group Position = 2 { 327 | optional string start_key = 27; 328 | 329 | repeated group IndexValue = 29 { 330 | optional string property = 30; 331 | required PropertyValue value = 31; 332 | } 333 | 334 | optional Reference key = 32; 335 | 336 | optional bool start_inclusive = 28 [default=true]; 337 | } 338 | } 339 | 340 | message Cursor { 341 | required fixed64 cursor = 1; 342 | 343 | optional string app = 2; 344 | } 345 | 346 | message Error { 347 | enum ErrorCode { 348 | BAD_REQUEST = 1; 349 | CONCURRENT_TRANSACTION = 2; 350 | INTERNAL_ERROR = 3; 351 | NEED_INDEX = 4; 352 | TIMEOUT = 5; 353 | PERMISSION_DENIED = 6; 354 | BIGTABLE_ERROR = 7; 355 | COMMITTED_BUT_STILL_APPLYING = 8; 356 | CAPABILITY_DISABLED = 9; 357 | TRY_ALTERNATE_BACKEND = 10; 358 | SAFE_TIME_TOO_OLD = 11; 359 | } 360 | } 361 | 362 | message Cost { 363 | optional int32 index_writes = 1; 364 | optional int32 index_write_bytes = 2; 365 | optional int32 entity_writes = 3; 366 | optional int32 entity_write_bytes = 4; 367 | optional group CommitCost = 5 { 368 | optional int32 requested_entity_puts = 6; 369 | optional int32 requested_entity_deletes = 7; 370 | }; 371 | optional int32 approximate_storage_delta = 8; 372 | optional int32 id_sequence_updates = 9; 373 | } 374 | 375 | message GetRequest { 376 | optional InternalHeader header = 6; 377 | 378 | repeated Reference key = 1; 379 | optional Transaction transaction = 2; 380 | 381 | optional int64 failover_ms = 3; 382 | 383 | optional bool strong = 4; 384 | 385 | optional bool allow_deferred = 5 [default=false]; 386 | } 387 | 388 | message GetResponse { 389 | repeated group Entity = 1 { 390 | optional EntityProto entity = 2; 391 | optional Reference key = 4; 392 | 393 | optional int64 version = 3; 394 | } 395 | 396 | repeated Reference deferred = 5; 397 | 398 | optional bool in_order = 6 [default=true]; 399 | } 400 | 401 | message PutRequest { 402 | optional InternalHeader header = 11; 403 | 404 | repeated EntityProto entity = 1; 405 | optional Transaction transaction = 2; 406 | repeated CompositeIndex composite_index = 3; 407 | 408 | optional bool trusted = 4 [default = false]; 409 | 410 | optional bool force = 7 [default = false]; 411 | 412 | optional bool mark_changes = 8 [default = false]; 413 | repeated Snapshot snapshot = 9; 414 | 415 | enum AutoIdPolicy { 416 | CURRENT = 0; 417 | SEQUENTIAL = 1; 418 | } 419 | optional AutoIdPolicy auto_id_policy = 10 [default = CURRENT]; 420 | } 421 | 422 | message PutResponse { 423 | repeated Reference key = 1; 424 | optional Cost cost = 2; 425 | repeated int64 version = 3; 426 | } 427 | 428 | message TouchRequest { 429 | optional InternalHeader header = 10; 430 | 431 | repeated Reference key = 1; 432 | repeated CompositeIndex composite_index = 2; 433 | optional bool force = 3 [default = false]; 434 | repeated Snapshot snapshot = 9; 435 | } 436 | 437 | message TouchResponse { 438 | optional Cost cost = 1; 439 | } 440 | 441 | message DeleteRequest { 442 | optional InternalHeader header = 10; 443 | 444 | repeated Reference key = 6; 445 | optional Transaction transaction = 5; 446 | 447 | optional bool trusted = 4 [default = false]; 448 | 449 | optional bool force = 7 [default = false]; 450 | 451 | optional bool mark_changes = 8 [default = false]; 452 | repeated Snapshot snapshot = 9; 453 | } 454 | 455 | message DeleteResponse { 456 | optional Cost cost = 1; 457 | repeated int64 version = 3; 458 | } 459 | 460 | message NextRequest { 461 | optional InternalHeader header = 5; 462 | 463 | required Cursor cursor = 1; 464 | optional int32 count = 2; 465 | 466 | optional int32 offset = 4 [default = 0]; 467 | 468 | optional bool compile = 3 [default = false]; 469 | } 470 | 471 | message QueryResult { 472 | optional Cursor cursor = 1; 473 | 474 | repeated EntityProto result = 2; 475 | 476 | optional int32 skipped_results = 7; 477 | 478 | required bool more_results = 3; 479 | 480 | optional bool keys_only = 4; 481 | 482 | optional bool index_only = 9; 483 | 484 | optional bool small_ops = 10; 485 | 486 | optional CompiledQuery compiled_query = 5; 487 | 488 | optional CompiledCursor compiled_cursor = 6; 489 | 490 | repeated CompositeIndex index = 8; 491 | 492 | repeated int64 version = 11; 493 | } 494 | 495 | message AllocateIdsRequest { 496 | optional InternalHeader header = 4; 497 | 498 | optional Reference model_key = 1; 499 | 500 | optional int64 size = 2; 501 | 502 | optional int64 max = 3; 503 | 504 | repeated Reference reserve = 5; 505 | } 506 | 507 | message AllocateIdsResponse { 508 | required int64 start = 1; 509 | required int64 end = 2; 510 | optional Cost cost = 3; 511 | } 512 | 513 | message CompositeIndices { 514 | repeated CompositeIndex index = 1; 515 | } 516 | 517 | message AddActionsRequest { 518 | optional InternalHeader header = 3; 519 | 520 | required Transaction transaction = 1; 521 | repeated Action action = 2; 522 | } 523 | 524 | message AddActionsResponse { 525 | } 526 | 527 | message BeginTransactionRequest { 528 | optional InternalHeader header = 3; 529 | 530 | required string app = 1; 531 | optional bool allow_multiple_eg = 2 [default = false]; 532 | } 533 | 534 | message CommitResponse { 535 | optional Cost cost = 1; 536 | 537 | repeated group Version = 3 { 538 | required Reference root_entity_key = 4; 539 | required int64 version = 5; 540 | } 541 | } 542 | -------------------------------------------------------------------------------- /backup/prop.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | package backup 6 | 7 | import ( 8 | "fmt" 9 | "reflect" 10 | "strings" 11 | "sync" 12 | "unicode" 13 | ) 14 | 15 | // Entities with more than this many indexed properties will not be saved. 16 | const maxIndexedProperties = 20000 17 | 18 | // []byte fields more than 1 megabyte long will not be loaded or saved. 19 | const maxBlobLen = 1 << 20 20 | 21 | // Property is a name/value pair plus some metadata. A datastore entity's 22 | // contents are loaded and saved as a sequence of Properties. An entity can 23 | // have multiple Properties with the same name, provided that p.Multiple is 24 | // true on all of that entity's Properties with that name. 25 | type Property struct { 26 | // Name is the property name. 27 | Name string 28 | // Value is the property value. The valid types are: 29 | // - int64 30 | // - bool 31 | // - string 32 | // - float64 33 | // - ByteString 34 | // - *Key 35 | // - time.Time 36 | // - appengine.BlobKey 37 | // - appengine.GeoPoint 38 | // - []byte (up to 1 megabyte in length) 39 | // This set is smaller than the set of valid struct field types that the 40 | // datastore can load and save. A Property Value cannot be a slice (apart 41 | // from []byte); use multiple Properties instead. Also, a Value's type 42 | // must be explicitly on the list above; it is not sufficient for the 43 | // underlying type to be on that list. For example, a Value of "type 44 | // myInt64 int64" is invalid. Smaller-width integers and floats are also 45 | // invalid. Again, this is more restrictive than the set of valid struct 46 | // field types. 47 | // 48 | // A Value will have an opaque type when loading entities from an index, 49 | // such as via a projection query. Load entities into a struct instead 50 | // of a PropertyLoadSaver when using a projection query. 51 | // 52 | // A Value may also be the nil interface value; this is equivalent to 53 | // Python's None but not directly representable by a Go struct. Loading 54 | // a nil-valued property into a struct will set that field to the zero 55 | // value. 56 | Value interface{} 57 | // NoIndex is whether the datastore cannot index this property. 58 | NoIndex bool 59 | // Multiple is whether the entity can have multiple properties with 60 | // the same name. Even if a particular instance only has one property with 61 | // a certain name, Multiple should be true if a struct would best represent 62 | // it as a field of type []T instead of type T. 63 | Multiple bool 64 | } 65 | 66 | // ByteString is a short byte slice (up to 1500 bytes) that can be indexed. 67 | type ByteString []byte 68 | 69 | // PropertyLoadSaver can be converted from and to a slice of Properties. 70 | type PropertyLoadSaver interface { 71 | Load([]Property) error 72 | Save() ([]Property, error) 73 | } 74 | 75 | // PropertyList converts a []Property to implement PropertyLoadSaver. 76 | type PropertyList []Property 77 | 78 | var ( 79 | typeOfPropertyLoadSaver = reflect.TypeOf((*PropertyLoadSaver)(nil)).Elem() 80 | typeOfPropertyList = reflect.TypeOf(PropertyList(nil)) 81 | ) 82 | 83 | // Load loads all of the provided properties into l. 84 | // It does not first reset *l to an empty slice. 85 | func (l *PropertyList) Load(p []Property) error { 86 | *l = append(*l, p...) 87 | return nil 88 | } 89 | 90 | // Save saves all of l's properties as a slice or Properties. 91 | func (l *PropertyList) Save() ([]Property, error) { 92 | return *l, nil 93 | } 94 | 95 | // validPropertyName returns whether name consists of one or more valid Go 96 | // identifiers joined by ".". 97 | func validPropertyName(name string) bool { 98 | if name == "" { 99 | return false 100 | } 101 | for _, s := range strings.Split(name, ".") { 102 | if s == "" { 103 | return false 104 | } 105 | first := true 106 | for _, c := range s { 107 | if first { 108 | first = false 109 | if c != '_' && !unicode.IsLetter(c) { 110 | return false 111 | } 112 | } else { 113 | if c != '_' && !unicode.IsLetter(c) && !unicode.IsDigit(c) { 114 | return false 115 | } 116 | } 117 | } 118 | } 119 | return true 120 | } 121 | 122 | // structTag is the parsed `datastore:"name,options"` tag of a struct field. 123 | // If a field has no tag, or the tag has an empty name, then the structTag's 124 | // name is just the field name. A "-" name means that the datastore ignores 125 | // that field. 126 | type structTag struct { 127 | name string 128 | noIndex bool 129 | } 130 | 131 | // structCodec describes how to convert a struct to and from a sequence of 132 | // properties. 133 | type structCodec struct { 134 | // byIndex gives the structTag for the i'th field. 135 | byIndex []structTag 136 | // byName gives the field codec for the structTag with the given name. 137 | byName map[string]fieldCodec 138 | // hasSlice is whether a struct or any of its nested or embedded structs 139 | // has a slice-typed field (other than []byte). 140 | hasSlice bool 141 | // complete is whether the structCodec is complete. An incomplete 142 | // structCodec may be encountered when walking a recursive struct. 143 | complete bool 144 | } 145 | 146 | // fieldCodec is a struct field's index and, if that struct field's type is 147 | // itself a struct, that substruct's structCodec. 148 | type fieldCodec struct { 149 | index int 150 | substructCodec *structCodec 151 | } 152 | 153 | // structCodecs collects the structCodecs that have already been calculated. 154 | var ( 155 | structCodecsMutex sync.Mutex 156 | structCodecs = make(map[reflect.Type]*structCodec) 157 | ) 158 | 159 | // getStructCodec returns the structCodec for the given struct type. 160 | func getStructCodec(t reflect.Type) (*structCodec, error) { 161 | structCodecsMutex.Lock() 162 | defer structCodecsMutex.Unlock() 163 | return getStructCodecLocked(t) 164 | } 165 | 166 | // getStructCodecLocked implements getStructCodec. The structCodecsMutex must 167 | // be held when calling this function. 168 | func getStructCodecLocked(t reflect.Type) (ret *structCodec, retErr error) { 169 | c, ok := structCodecs[t] 170 | if ok { 171 | return c, nil 172 | } 173 | c = &structCodec{ 174 | byIndex: make([]structTag, t.NumField()), 175 | byName: make(map[string]fieldCodec), 176 | } 177 | 178 | // Add c to the structCodecs map before we are sure it is good. If t is 179 | // a recursive type, it needs to find the incomplete entry for itself in 180 | // the map. 181 | structCodecs[t] = c 182 | defer func() { 183 | if retErr != nil { 184 | delete(structCodecs, t) 185 | } 186 | }() 187 | 188 | for i := range c.byIndex { 189 | f := t.Field(i) 190 | name, opts := f.Tag.Get("datastore"), "" 191 | if i := strings.Index(name, ","); i != -1 { 192 | name, opts = name[:i], name[i+1:] 193 | } 194 | if name == "" { 195 | if !f.Anonymous { 196 | name = f.Name 197 | } 198 | } else if name == "-" { 199 | c.byIndex[i] = structTag{name: name} 200 | continue 201 | } else if !validPropertyName(name) { 202 | return nil, fmt.Errorf("datastore: struct tag has invalid property name: %q", name) 203 | } 204 | 205 | substructType, fIsSlice := reflect.Type(nil), false 206 | switch f.Type.Kind() { 207 | case reflect.Struct: 208 | substructType = f.Type 209 | case reflect.Slice: 210 | if f.Type.Elem().Kind() == reflect.Struct { 211 | substructType = f.Type.Elem() 212 | } 213 | fIsSlice = f.Type != typeOfByteSlice 214 | c.hasSlice = c.hasSlice || fIsSlice 215 | } 216 | 217 | if substructType != nil && substructType != typeOfTime && substructType != typeOfGeoPoint { 218 | if name != "" { 219 | name = name + "." 220 | } 221 | sub, err := getStructCodecLocked(substructType) 222 | if err != nil { 223 | return nil, err 224 | } 225 | if !sub.complete { 226 | return nil, fmt.Errorf("datastore: recursive struct: field %q", f.Name) 227 | } 228 | if fIsSlice && sub.hasSlice { 229 | return nil, fmt.Errorf( 230 | "datastore: flattening nested structs leads to a slice of slices: field %q", f.Name) 231 | } 232 | c.hasSlice = c.hasSlice || sub.hasSlice 233 | for relName := range sub.byName { 234 | absName := name + relName 235 | if _, ok := c.byName[absName]; ok { 236 | return nil, fmt.Errorf("datastore: struct tag has repeated property name: %q", absName) 237 | } 238 | c.byName[absName] = fieldCodec{index: i, substructCodec: sub} 239 | } 240 | } else { 241 | if _, ok := c.byName[name]; ok { 242 | return nil, fmt.Errorf("datastore: struct tag has repeated property name: %q", name) 243 | } 244 | c.byName[name] = fieldCodec{index: i} 245 | } 246 | 247 | c.byIndex[i] = structTag{ 248 | name: name, 249 | noIndex: opts == "noindex", 250 | } 251 | } 252 | c.complete = true 253 | return c, nil 254 | } 255 | 256 | // structPLS adapts a struct to be a PropertyLoadSaver. 257 | type structPLS struct { 258 | v reflect.Value 259 | codec *structCodec 260 | } 261 | 262 | // newStructPLS returns a PropertyLoadSaver for the struct pointer p. 263 | func newStructPLS(p interface{}) (PropertyLoadSaver, error) { 264 | v := reflect.ValueOf(p) 265 | if v.Kind() != reflect.Ptr || v.Elem().Kind() != reflect.Struct { 266 | return nil, ErrInvalidEntityType 267 | } 268 | v = v.Elem() 269 | codec, err := getStructCodec(v.Type()) 270 | if err != nil { 271 | return nil, err 272 | } 273 | return structPLS{v, codec}, nil 274 | } 275 | 276 | // LoadStruct loads the properties from p to dst. 277 | // dst must be a struct pointer. 278 | func LoadStruct(dst interface{}, p []Property) error { 279 | x, err := newStructPLS(dst) 280 | if err != nil { 281 | return err 282 | } 283 | return x.Load(p) 284 | } 285 | 286 | // SaveStruct returns the properties from src as a slice of Properties. 287 | // src must be a struct pointer. 288 | func SaveStruct(src interface{}) ([]Property, error) { 289 | x, err := newStructPLS(src) 290 | if err != nil { 291 | return nil, err 292 | } 293 | return x.Save() 294 | } 295 | -------------------------------------------------------------------------------- /backup/save.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | package backup 6 | 7 | import ( 8 | "errors" 9 | "fmt" 10 | "math" 11 | "reflect" 12 | "time" 13 | 14 | "github.com/golang/protobuf/proto" 15 | 16 | "google.golang.org/appengine" 17 | pb "github.com/sromku/datastore-to-sql/backup/pb" 18 | ) 19 | 20 | func toUnixMicro(t time.Time) int64 { 21 | // We cannot use t.UnixNano() / 1e3 because we want to handle times more than 22 | // 2^63 nanoseconds (which is about 292 years) away from 1970, and those cannot 23 | // be represented in the numerator of a single int64 divide. 24 | return t.Unix()*1e6 + int64(t.Nanosecond()/1e3) 25 | } 26 | 27 | func fromUnixMicro(t int64) time.Time { 28 | return time.Unix(t/1e6, (t%1e6)*1e3) 29 | } 30 | 31 | var ( 32 | minTime = time.Unix(int64(math.MinInt64)/1e6, (int64(math.MinInt64)%1e6)*1e3) 33 | maxTime = time.Unix(int64(math.MaxInt64)/1e6, (int64(math.MaxInt64)%1e6)*1e3) 34 | ) 35 | 36 | // valueToProto converts a named value to a newly allocated Property. 37 | // The returned error string is empty on success. 38 | func valueToProto(defaultAppID, name string, v reflect.Value, multiple bool) (p *pb.Property, errStr string) { 39 | var ( 40 | pv pb.PropertyValue 41 | unsupported bool 42 | ) 43 | switch v.Kind() { 44 | case reflect.Invalid: 45 | // No-op. 46 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 47 | pv.Int64Value = proto.Int64(v.Int()) 48 | case reflect.Bool: 49 | pv.BooleanValue = proto.Bool(v.Bool()) 50 | case reflect.String: 51 | pv.StringValue = proto.String(v.String()) 52 | case reflect.Float32, reflect.Float64: 53 | pv.DoubleValue = proto.Float64(v.Float()) 54 | case reflect.Ptr: 55 | if k, ok := v.Interface().(*Key); ok { 56 | if k != nil { 57 | pv.Referencevalue = keyToReferenceValue(defaultAppID, k) 58 | } 59 | } else { 60 | unsupported = true 61 | } 62 | case reflect.Struct: 63 | switch t := v.Interface().(type) { 64 | case time.Time: 65 | if t.Before(minTime) || t.After(maxTime) { 66 | return nil, "time value out of range" 67 | } 68 | pv.Int64Value = proto.Int64(toUnixMicro(t)) 69 | case appengine.GeoPoint: 70 | if !t.Valid() { 71 | return nil, "invalid GeoPoint value" 72 | } 73 | // NOTE: Strangely, latitude maps to X, longitude to Y. 74 | pv.Pointvalue = &pb.PropertyValue_PointValue{X: &t.Lat, Y: &t.Lng} 75 | default: 76 | unsupported = true 77 | } 78 | case reflect.Slice: 79 | if b, ok := v.Interface().([]byte); ok { 80 | pv.StringValue = proto.String(string(b)) 81 | } else { 82 | // nvToProto should already catch slice values. 83 | // If we get here, we have a slice of slice values. 84 | unsupported = true 85 | } 86 | default: 87 | unsupported = true 88 | } 89 | if unsupported { 90 | return nil, "unsupported datastore value type: " + v.Type().String() 91 | } 92 | p = &pb.Property{ 93 | Name: proto.String(name), 94 | Value: &pv, 95 | Multiple: proto.Bool(multiple), 96 | } 97 | if v.IsValid() { 98 | switch v.Interface().(type) { 99 | case []byte: 100 | p.Meaning = pb.Property_BLOB.Enum() 101 | case ByteString: 102 | p.Meaning = pb.Property_BYTESTRING.Enum() 103 | case appengine.BlobKey: 104 | p.Meaning = pb.Property_BLOBKEY.Enum() 105 | case time.Time: 106 | p.Meaning = pb.Property_GD_WHEN.Enum() 107 | case appengine.GeoPoint: 108 | p.Meaning = pb.Property_GEORSS_POINT.Enum() 109 | } 110 | } 111 | return p, "" 112 | } 113 | 114 | func saveStructProperty(props *[]Property, name string, noIndex, multiple bool, v reflect.Value) error { 115 | p := Property{ 116 | Name: name, 117 | NoIndex: noIndex, 118 | Multiple: multiple, 119 | } 120 | switch x := v.Interface().(type) { 121 | case *Key: 122 | p.Value = x 123 | case time.Time: 124 | p.Value = x 125 | case appengine.BlobKey: 126 | p.Value = x 127 | case appengine.GeoPoint: 128 | p.Value = x 129 | case ByteString: 130 | p.Value = x 131 | default: 132 | switch v.Kind() { 133 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 134 | p.Value = v.Int() 135 | case reflect.Bool: 136 | p.Value = v.Bool() 137 | case reflect.String: 138 | p.Value = v.String() 139 | case reflect.Float32, reflect.Float64: 140 | p.Value = v.Float() 141 | case reflect.Slice: 142 | if v.Type().Elem().Kind() == reflect.Uint8 { 143 | p.NoIndex = true 144 | p.Value = v.Bytes() 145 | } 146 | case reflect.Struct: 147 | if !v.CanAddr() { 148 | return fmt.Errorf("datastore: unsupported struct field: value is unaddressable") 149 | } 150 | sub, err := newStructPLS(v.Addr().Interface()) 151 | if err != nil { 152 | return fmt.Errorf("datastore: unsupported struct field: %v", err) 153 | } 154 | return sub.(structPLS).save(props, name, noIndex, multiple) 155 | } 156 | } 157 | if p.Value == nil { 158 | return fmt.Errorf("datastore: unsupported struct field type: %v", v.Type()) 159 | } 160 | *props = append(*props, p) 161 | return nil 162 | } 163 | 164 | func (s structPLS) Save() ([]Property, error) { 165 | var props []Property 166 | if err := s.save(&props, "", false, false); err != nil { 167 | return nil, err 168 | } 169 | return props, nil 170 | } 171 | 172 | func (s structPLS) save(props *[]Property, prefix string, noIndex, multiple bool) error { 173 | for i, t := range s.codec.byIndex { 174 | if t.name == "-" { 175 | continue 176 | } 177 | name := t.name 178 | if prefix != "" { 179 | name = prefix + name 180 | } 181 | v := s.v.Field(i) 182 | if !v.IsValid() || !v.CanSet() { 183 | continue 184 | } 185 | noIndex1 := noIndex || t.noIndex 186 | // For slice fields that aren't []byte, save each element. 187 | if v.Kind() == reflect.Slice && v.Type().Elem().Kind() != reflect.Uint8 { 188 | for j := 0; j < v.Len(); j++ { 189 | if err := saveStructProperty(props, name, noIndex1, true, v.Index(j)); err != nil { 190 | return err 191 | } 192 | } 193 | continue 194 | } 195 | // Otherwise, save the field itself. 196 | if err := saveStructProperty(props, name, noIndex1, multiple, v); err != nil { 197 | return err 198 | } 199 | } 200 | return nil 201 | } 202 | 203 | func propertiesToProto(defaultAppID string, key *Key, props []Property) (*pb.EntityProto, error) { 204 | e := &pb.EntityProto{ 205 | Key: keyToProto(defaultAppID, key), 206 | } 207 | if key.parent == nil { 208 | e.EntityGroup = &pb.Path{} 209 | } else { 210 | e.EntityGroup = keyToProto(defaultAppID, key.root()).Path 211 | } 212 | prevMultiple := make(map[string]bool) 213 | 214 | for _, p := range props { 215 | if pm, ok := prevMultiple[p.Name]; ok { 216 | if !pm || !p.Multiple { 217 | return nil, fmt.Errorf("datastore: multiple Properties with Name %q, but Multiple is false", p.Name) 218 | } 219 | } else { 220 | prevMultiple[p.Name] = p.Multiple 221 | } 222 | 223 | x := &pb.Property{ 224 | Name: proto.String(p.Name), 225 | Value: new(pb.PropertyValue), 226 | Multiple: proto.Bool(p.Multiple), 227 | } 228 | switch v := p.Value.(type) { 229 | case int64: 230 | x.Value.Int64Value = proto.Int64(v) 231 | case bool: 232 | x.Value.BooleanValue = proto.Bool(v) 233 | case string: 234 | x.Value.StringValue = proto.String(v) 235 | if p.NoIndex { 236 | x.Meaning = pb.Property_TEXT.Enum() 237 | } 238 | case float64: 239 | x.Value.DoubleValue = proto.Float64(v) 240 | case *Key: 241 | if v != nil { 242 | x.Value.Referencevalue = keyToReferenceValue(defaultAppID, v) 243 | } 244 | case time.Time: 245 | if v.Before(minTime) || v.After(maxTime) { 246 | return nil, fmt.Errorf("datastore: time value out of range") 247 | } 248 | x.Value.Int64Value = proto.Int64(toUnixMicro(v)) 249 | x.Meaning = pb.Property_GD_WHEN.Enum() 250 | case appengine.BlobKey: 251 | x.Value.StringValue = proto.String(string(v)) 252 | x.Meaning = pb.Property_BLOBKEY.Enum() 253 | case appengine.GeoPoint: 254 | if !v.Valid() { 255 | return nil, fmt.Errorf("datastore: invalid GeoPoint value") 256 | } 257 | // NOTE: Strangely, latitude maps to X, longitude to Y. 258 | x.Value.Pointvalue = &pb.PropertyValue_PointValue{X: &v.Lat, Y: &v.Lng} 259 | x.Meaning = pb.Property_GEORSS_POINT.Enum() 260 | case []byte: 261 | x.Value.StringValue = proto.String(string(v)) 262 | x.Meaning = pb.Property_BLOB.Enum() 263 | if !p.NoIndex { 264 | return nil, fmt.Errorf("datastore: cannot index a []byte valued Property with Name %q", p.Name) 265 | } 266 | case ByteString: 267 | x.Value.StringValue = proto.String(string(v)) 268 | x.Meaning = pb.Property_BYTESTRING.Enum() 269 | default: 270 | if p.Value != nil { 271 | return nil, fmt.Errorf("datastore: invalid Value type for a Property with Name %q", p.Name) 272 | } 273 | } 274 | 275 | if p.NoIndex { 276 | e.RawProperty = append(e.RawProperty, x) 277 | } else { 278 | e.Property = append(e.Property, x) 279 | if len(e.Property) > maxIndexedProperties { 280 | return nil, errors.New("datastore: too many indexed properties") 281 | } 282 | } 283 | } 284 | return e, nil 285 | } 286 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /example/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/sromku/datastore-to-sql/backup" 6 | ) 7 | 8 | func main() { 9 | 10 | backupPaths := []string{ 11 | "../exported-data/data/datastore_backup_datastore_backup_2016_02_07_Profile/157249940434231075281045461947F/output-0", 12 | } 13 | 14 | for _, backupPath := range backupPaths { 15 | 16 | backup.Load(backupPath, &Profile{}, 17 | 18 | // if you want to prepare something before loading into model 19 | func(res interface{}) { 20 | profile, _ := res.(*Profile) 21 | profile.Name = "" 22 | profile.Email = "" 23 | profile.Gender = 0 24 | }, 25 | 26 | // process the loaded model 27 | func(res interface{}) { 28 | profile, _ := res.(*Profile) 29 | insert := "INSERT INTO `users` (name,email,gender) VALUES ('%v','%v',%v);" 30 | insert = fmt.Sprintf(insert, profile.Name, profile.Email, profile.Gender) 31 | fmt.Println(insert) 32 | }) 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /example/model.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Profile struct { 4 | Name string `datastore:"name, noindex"` 5 | Email string `datastore:"email"` 6 | Gender int `datastore:"gender, noindex"` 7 | } -------------------------------------------------------------------------------- /exported-data/data/ahZzfm1pZ3JhdGlvbi1zcWwtc2FtcGxlckELEhxfQUVfRGF0YXN0b3JlQWRtaW5fT3BlcmF0aW9uGIGb7gIMCxIWX0FFX0JhY2t1cF9JbmZvcm1hdGlvbhgBDA.Profile.backup_info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sromku/datastore-to-sql/5a2215bf7384a09652137d39d9423c989bfa16c9/exported-data/data/ahZzfm1pZ3JhdGlvbi1zcWwtc2FtcGxlckELEhxfQUVfRGF0YXN0b3JlQWRtaW5fT3BlcmF0aW9uGIGb7gIMCxIWX0FFX0JhY2t1cF9JbmZvcm1hdGlvbhgBDA.Profile.backup_info -------------------------------------------------------------------------------- /exported-data/data/ahZzfm1pZ3JhdGlvbi1zcWwtc2FtcGxlckELEhxfQUVfRGF0YXN0b3JlQWRtaW5fT3BlcmF0aW9uGIGb7gIMCxIWX0FFX0JhY2t1cF9JbmZvcm1hdGlvbhgBDA.backup_info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sromku/datastore-to-sql/5a2215bf7384a09652137d39d9423c989bfa16c9/exported-data/data/ahZzfm1pZ3JhdGlvbi1zcWwtc2FtcGxlckELEhxfQUVfRGF0YXN0b3JlQWRtaW5fT3BlcmF0aW9uGIGb7gIMCxIWX0FFX0JhY2t1cF9JbmZvcm1hdGlvbhgBDA.backup_info -------------------------------------------------------------------------------- /exported-data/data/datastore_backup_datastore_backup_2016_02_07_Profile/157249940434231075281045461947F/output-0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sromku/datastore-to-sql/5a2215bf7384a09652137d39d9423c989bfa16c9/exported-data/data/datastore_backup_datastore_backup_2016_02_07_Profile/157249940434231075281045461947F/output-0 -------------------------------------------------------------------------------- /sample-server/.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /sample-server/app.yaml: -------------------------------------------------------------------------------- 1 | application: migration-sql-sample 2 | version: 1 3 | runtime: go 4 | api_version: go1 5 | 6 | handlers: 7 | - url: / 8 | script: _go_app 9 | 10 | -------------------------------------------------------------------------------- /sample-server/main.go: -------------------------------------------------------------------------------- 1 | package sromku 2 | 3 | import ( 4 | "net/http" 5 | "github.com/gorilla/mux" 6 | "appengine" 7 | "appengine/datastore" 8 | "fmt" 9 | ) 10 | 11 | func init() { 12 | r := mux.NewRouter() 13 | r.HandleFunc("/", handle).Methods("GET") 14 | http.Handle("/", r) 15 | } 16 | 17 | func handle(w http.ResponseWriter, r *http.Request) { 18 | ctx := appengine.NewContext(r) 19 | putUser("Alban Lestat", "alban.lestat@gmail.com", 0, ctx) 20 | putUser("Erik Erich", "erik.erich@gmail.com", 0, ctx) 21 | putUser("Aindrea Tim", "aindrea.tim@gmail.com", 1, ctx) 22 | putUser("Luisita Karolina", "luisita.karolina@gmail.com", 1, ctx) 23 | fmt.Fprintln(w, "4 users saved in datastore") 24 | } 25 | 26 | func putUser(name, email string, gender int, ctx appengine.Context) { 27 | key := datastore.NewKey(ctx, "Profile", email, 0, nil) 28 | datastore.Put(ctx, key, &Profile{ 29 | Name:name, 30 | Email:email, 31 | Gender:gender, 32 | }) 33 | } 34 | 35 | type Profile struct { 36 | Name string `datastore:"name, noindex"` 37 | Email string `datastore:"email"` 38 | Gender int `datastore:"gender, noindex"` 39 | } 40 | --------------------------------------------------------------------------------