2
votes

I'm developing an Android app with Google Cloud Endpoints, I have read a lot of documentation and tutorials about it, but there is still one information missing: How can I choose which backend's methods will be visible for Android client?
Let's say I have a FriendshipEndpoint, FriendshipEndpoint has this method:

@ApiMethod(name = "listFriendship", path = "listFriendship")
public CollectionResponse<Friendship> listFriendship(
        @Nullable @Named("cursor") String cursorString,
        @Nullable @Named("limit") Integer limit)

EDIT FriendshipEndpoint is annotated with @Api annotation

This method should be visible only in the backend (not by Android client).

I have tried to remove @ApiMethod anotation -> doesn't work, the method is still visible in the api explorer in my browser.
Setting access modifier to private is not a solution for me, because I want to call this method from other Endpoint.
Removing access modifier is also no solution for me, because I need this method to be visible from other packages (test package).

Is there a solution for this problem at all?

1
When you removed the @ApiMethod annotation, did you re-run update and endpoints_get_client_lib maven goals? The annotation is what will cause the method to be excluded from the cloud API exposed via REST and the client library. - Larry Schiefer
@LarrySchiefer I didn't regenerate the cloud endpoints library, but after I rerun the project without @ApiMethod annotation, the method was still "visible for the world", so it could also be callable by Android client. What you are saying is in contrary with "all public, non static, non bridge methods in a class with an @Api annotation are exposed in the API, whether they have an @ApiMethod annotation or not." [1], isn't it? My Endpoint is also annotated with @Api annotation. (cloud.google.com/appengine/docs/java/endpoints/…) - FilipR
You are correct, I'd forgotten the top level @Api annotation. My apologies for the confusion. - Larry Schiefer

1 Answers

0
votes

Unfortunately, this scenario is not supported right now. The best solution is to move the method to a helper class and have it shared among all the endpoint classes.