I'm defining an endpoint modeling a user as below. I can query a user by id. But how can I get that id when inserting the user? My client is written in java but I'd like to know how to retrive the id both with python as well as with the generated java client libs.
from google.appengine.ext import endpoints
from google.appengine.ext import ndb
from protorpc import remote
from endpoints_proto_datastore.ndb import EndpointsModel
class User(EndpointsModel):
email = ndb.StringProperty(required=True)
phone_number = ndb.StringProperty()
reg_id = ndb.StringProperty()
created = ndb.DateTimeProperty(auto_now_add=True)
@endpoints.api(name='whereareyoudroid',
version='v1', description='Where Are You Users')
class UserApi(remote.Service):
@User.method(name='user.insert', path='user')
def insert(self, user):
user.put()
return user
@User.method(request_fields=('id',),
path='user/{id}',
http_method='GET', name='user.get')
def get(self, user):
if not User.from_datastore:
raise endpoints.NotFoundException('User not found.')
return user