If you have, say, an EndpointsModel class, Employee, which contains a reference to an EndpointsModel class, Company, how do you include a method in the remote.Service class CompanyService that lists its employees?
The question might better be phrased as" "How to access a query variable within a method?"
The path might look like so:
GET http://localhost:8080/_ah/api/contacts/v1/companies/123/employees
Here's CompanyService::employees():
@Employee.query_method(http_method='GET', path='companies/{id}/employees')
def employees(self, company):
"""
Retrieve the employees for this company
"""
company_key = ndb.Key(Company, company)
return Employee.query(Employee.company == company_key).fetch(20)
When company_key is computed using a hardcoded value, say '123', This method actually works perfectly. But how to get the company id? In "query" methods, as opposed to "query_method" methods, this is simply an attribute of the model parameter with which the method is called. But there doesn't seem to be an easy way to extract the value from the query parameter with which a "query_method" method is called.
Since this is a central design feature of any API I would like to create, I really need to get it worked out. The engineering boilerplate comprising the EPD and endpoints libraries provide some good documentation in the comments but the code itself is above my pay grade :-)