<s> import random <EOL> import endpoints <EOL> from google . appengine . ext import ndb <EOL> from protorpc import remote <EOL> from endpoints_proto_datastore . ndb import EndpointsModel <EOL> PHRASES = [ '<STR_LIT:I>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> class MyModel ( EndpointsModel ) : <EOL> attr1 = ndb . StringProperty ( ) <EOL> attr2 = ndb . StringProperty ( ) <EOL> created = ndb . DateTimeProperty ( auto_now_add = True ) <EOL> @ endpoints . api ( name = '<STR_LIT>' , version = '<STR_LIT>' , description = '<STR_LIT>' ) <EOL> class MyApi ( remote . Service ) : <EOL> @ MyModel . method ( request_fields = ( '<STR_LIT>' , ) , <EOL> response_fields = ( '<STR_LIT>' , ) , <EOL> path = '<STR_LIT>' , <EOL> http_method = '<STR_LIT:POST>' , <EOL> name = '<STR_LIT>' ) <EOL> def MyModelInsert ( self , my_model ) : <EOL> my_model . attr2 = '<STR_LIT>' % ( my_model . attr1 , random . choice ( PHRASES ) ) <EOL> my_model . put ( ) <EOL> return my_model <EOL> @ MyModel . query_method ( collection_fields = ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> path = '<STR_LIT>' , name = '<STR_LIT>' ) <EOL> def MyModelList ( self , query ) : <EOL> return query <EOL> application = endpoints . api_server ( [ MyApi ] , restricted = False ) </s>
