I am starting to use Google Cloud Endpoints and I am running in a problem when specifying multiple services classes. Any idea how to get this working?
ApiConfigurationError: Attempting to implement service myservice, version v1, with multiple classes that aren't compatible. See docstring for api() for examples how to implement a multi-class API.
This is how I am creating my endpoint server.
AVAILABLE_SERVICES = [
FirstService,
SecondService
]
app = endpoints.api_server(AVAILABLE_SERVICES)
and for every service class I am doing this:
@endpoints.api(name='myservice', version='v1', description='MyService API')
class FirstService(remote.Service):
...
@endpoints.api(name='myservice', version='v1', description='MyService API')
class SecondService(remote.Service):
...
Each one of these work perfectly separately, but I am not sure how to get them working when combining them.
Thanks a lot.
For local development I'm using a temporary workaround, which is to disable the exception (I know I know...)
In my sdk in
google_appengine/google/appengine/ext/endpoints/api_backend_service.py
around line 97:In combination with that I'm using the construct:
Again, this won't work in production, you'll get the same exception there. Hopefully this answer will be obsoleted by a future fix.
Confirmed it's now obsolete (tested against 1.8.2).
The correct way is to create an
api
object and use thecollection
where resource name would be inserted in front of method names so that you could use
instead of
Putting this in the API server:
The
api_root
object is equivalent to aremote.Service
class decorated withendpoints.api
, so you can simply include it in theendpoints.api_server
list. For example:If I'm not mistaken, you should give different names to each service, so you'll be able to access both, each one with the specific "address".
If it was Java ...
cloudn't be easier.
I've managed to successfuly deploy single api implemented in two classes. You can try using following snippet (almost directly from google documentation):