javajsongoogle-apigoogle-drive-apistability

Stabillity in Drive API java app


I am not sure this is the right place for this kind of question, if not, please point me in the right direction - thanks.

After searching a lot in many different places, I think You are my last hope :)

I have used the Google Drive API V3 Quickstart sample and I have it working however I have a few concerns.

I wonder what would happen if Google changes the API by adding a new functionality to the com.google.api.services.drive.model.File when I call the different methods (like getId() og getName()) to get the info i need from my files. See the last System.out.printf() in the sample below.

Sample code:

...
 public static void main(String[] args) throws IOException {

    // Build a new authorized API client service.
    Drive service = getDriveService();

    // Print the names and IDs for up to 10 files.
    FileList result = service.files().list()
         .setPageSize(10)
         .setFields("nextPageToken, files(id, name)")
         .execute();
    List<File> files = result.getFiles();
    if (files == null || files.size() == 0) {
        System.out.println("No files found.");
    } else {
        System.out.println("Files:");
        for (File file : files) {
            System.out.printf("%s (%s)\n", file.getName(), file.getId());
        }
    }
}
....

Is something like that (adding new methods to the API) going to break the code?

I´ll of course be using any relevant error handling, however I don't really want to have to go back and change something in the code because new stuff have been added from third part.

Maybe what i´m asking is how the conversion of JSON is handled "behind the scenes" and if this conversation can handle new members to the JSON code without breaking..

Maybe Google never changes anything and just provide us with a new version of the API

I´m sure Google have thought of this, but thats not an acceptable argument to my client :)

I really appreciate any help in this matter.


Solution

  • What you are doing right now is using the Google-apis-java-client library to access the Google Drive API v3 So you really have two things to consider here.

    Google Drive API V3:

    Lets look at the api itself first. The Google Drive API v3 is rather new it was released in 2016 if there are any bugs Google will release bug fixes. I have been working with Google APIs for five years now. Google does not release breaking changes into there APIs. They do release enhancements and or bug fixes from time to time. Google is not a fan of breaking changes. For the most part your code should continue to work against the API even if google makes changes on their end. In my time working with Google APIs i have never seen them release anything that out right broke my code.

    Client library

    Now lets consider the Google API client library for java. This is just a bunch of jar files that make it easier for you to access the API. For the most part Google Client libraries are generated code. So if there are changes in the Drive API the client library will be rebuilt to pick up any changes. If you don't update the jar file in your project then your project will continue to work you just wont have access to any of the new features that may have been added to the API itself. If you do decide to update to the newest jar file you will then be able to take advantage of any new features or bug fixes and your code should still continue to work. The teams who work with these client libraries very rarely introduce breaking changes.

    I am aware of a few breaking changes there were introduced into the Google API .net client library over the years. When we find them we are always very good at fixing them quickly. I would be willing to bet that the Java client library team is the same. It could happen but the risk IMO is very minimal, I was not personally affected by any of these issues.

    Anwsers:

    Is something like that (adding new methods to the API) going to break the code?

    It should not.

    Maybe what i´m asking is how the conversion of JSON is handled "behind the scenes".

    The library should handle this. Don't worry about it.

    Maybe Google never changes anything and just provide us with a new version of the API

    Drive V3 just came out if they release a new one its probably five years away and then you will probably have at least three years after that before they deprecate v3. Meaning that you could leave your code running for maybe ten years before there is a problem.

    I´m sure Google have thought of this, but thats not an acceptable argument to my client :)

    Clients are very hard to reassure. It is understandable. Just try and tell them that Google has been doing this for years and that they always try to ensure that nothing they will do will break existing solutions.