I'm coding an API via Google Cloud Endpoints and the endpoints-proto-datastore library.
Here's my model:
class Domain(EndpointsModel):
    _message_fields_schema = ('id', 'name', 'enabled', 'adminEmails')
    name = ndb.StringProperty(required=True)
    enabled = ndb.BooleanProperty(required=True)
    adminEmails = ndb.StringProperty(repeated=True)
And this is my delete method:
@Domain.method(request_fields=('id',), path='domains/{id}', http_method='DELETE', name='domain.delete')
def delete_domain(self, domain):
    if not domain.from_datastore:
        raise endpoints.NotFoundException('Domain not found.')
    domain._key.delete()
    return domain
Can I return something else than the model itself? How do I return a specific HTTP Status code or something like VoidMessage?
                        
You can define a
response_messageparameter in the decorator (as opposed to the more commonly usedresponse_fieldsparameter) and set it toVoidMessage. And then return aVoidMessagefrom your method instead of the model.Of course you can also return any other protorpc Message that way. As far as I know there's no way to define what HTTP Status Code to return though.