First, to answer your question:
By default, the message schema for your requests and response will be the fields on your model: email
, phone_number
, reg_id
, and created
. As is done in the simple get sample, you can change this default to include id
via
class User(EndpointsModel):
_message_fields_schema = ('id', 'email', 'phone_number',
'reg_id', 'created')
email = ndb.StringProperty(required=True)
...
or by specifying the response fields you want returned in the insert method
:
@User.method(response_fields=('id', 'email', 'phone_number',
'reg_id', 'created'),
name='user.insert', path='user')
def insert(self, user):
user.put()
return user
Second, you have a typo/mistake in get
:
The statement if not User.from_datastore:
will check if the User.from_datastore
property object on the User
class is "truthy", which it is. You want the actual value of this property on the user object: user.from_datastore
.