1
votes

I have an Android-Application project and an AppEngine-BackEnd project which serves as the back-end for the android app. I use Google Plugin to generate client libraries for the android client from the appengine project.

The AppEngine-BackEnd defines an endpoint 'AppEndPoint'. I've published the first version of the android app and appengine app.

Now I want to make some modifications to the endpoint eventually changing the API version to 'v2'.

What I did

In AppEngine project I duplicated the existing AppEndPoint class and renamed it to AppEndPointV2 and made required modifications to the new class. Also annotated the new class with version="v2". When I deployed the app could see both v1 and v2 versions available in the API explorer as expected.

Now when I generate the client libraries with the Google Plugin (Eclipse) for the android app it exports both v1 and v2 and it generates error "The type Appendpoint is already defined"

I expect only v2 to be present in the newly exported client library. So from this I feel there's something wrong in my approach. I searched a lot over the web and StackOverflow. But couldn't get the exact way to do this. Mainly searching was a bit difficult because the keywords 'endpoint', 'api', 'version' etc are very generic.

What I want

  1. My existing (already published client app) should still be able to access v1 of the API.
  2. The new app should be using v2

So I would like to know

  1. What is the recommended way to maintain different versions of an endpoint API. How the classes are to be written. Is duplicating the endpoint class on each version of the API and making changes to it the recommended way?
  2. How I can tell the plugin that I want only v2 of the endpoint to be exported to the endpoint client library?

Note : I'm using AppEngine-JAVA and eclipse is the IDE

1

1 Answers

0
votes

What is the recommended way to maintain different versions of an endpoint API. How the classes are to be written. Is duplicating the endpoint class on each version of the API and making changes to it the recommended way?

You are on the right track, ideally you build v1 and keep redepoying over it, once you deploy v2, your latest v1 will remain available for your legacy apps.

As for your "already defined" issue you should consider including a version marker in your endpoint and model's package. eg com.example.myendpoint.v2 .

This way you will be duplicating code (copying model classes and such) BUT you'll make sure your changes made to the new version don't break the previous version.