@MyModel.method(request_fields=('attr1',),
                  response_fields=('created',),
                  path='mymodel',
                  http_method='POST',
                  name='mymodel.insert')
  def MyModelInsert(self, my_model):
    # We use a random value from PHRASES to set attr2 in terms of attr1. Since
    # the request message can only contain a value for attr1, we need to also
    # provide a value for attr2.
    my_model.attr2 = '%s-%s' % (my_model.attr1, random.choice(PHRASES))
    # As in basic/main.py, since created is auto_now_add, the entity gets a new
    # value for created and an ID after being persisted.
    my_model.put()
    return my_model

  # As above, in addition to the arguments used in the MyModel.query_method
  # decorator in basic/main.py, we also use collection_fields to override
  # the schema of the ProtoRPC messages that are listed in the "items" fields
  # of the query response. As in basic/main.py, there are no query arguments.
  # Since collection_fields is ('attr2', 'created'), each value in the "items"
  # list will contain the two string fields corresponding to the NDB properties
  # attr2 and created.
dataset/ETHPy150Open GoogleCloudPlatform/endpoints-proto-datastore/examples/custom_api_response_messages/main.py/MyApi.MyModelInsert/original