google-api-java-client-services icon indicating copy to clipboard operation
google-api-java-client-services copied to clipboard

Question: Switched to single-parent model, will the library be updated?

Open palexdev opened this issue 5 years ago • 5 comments

Since now every file can have only one parent there's no reason to return a list of parents right? The query should be files(....parent....) and return type String parent

palexdev avatar Oct 01 '20 13:10 palexdev

This repository contains over 100 client libraries. Which client and endpoint are you referring to?

chingor13 avatar Oct 06 '20 17:10 chingor13

Oh right sorry, I'm referring to the drive api

palexdev avatar Oct 07 '20 12:10 palexdev

Looks like on Sept 30th 2020, Drive API was updated to single parent model. However, the API code has a class member called enforceSingleParent. (check Drive.java)

Setting this to true during API calls will be sufficient to change to Single Parent Model. The API implementation does not have to be changed to switch to Single Parent Model.

Hope this helps resolve the issue.

ganeshbch avatar Oct 11 '20 03:10 ganeshbch

@ganeshbhargav that doesn't mean anything. The single parent model allows one and only parent for each file, so that means one single String. Now, I don't know you but when I have to represent a single entity in a program/API I use a variable, not a collection. If I want to store my name I use a String not a List of strings. What I want to say is that right now that piece of code doesn't make any sense, it's a waste of memory and it is actually bad code (to be honest it was bad even before the single parent model) since we have to deal with a collection that could be null, in fact I think it's best to always initialize the List instead of returning null if the file has no parent. Some changes on server side are needed

palexdev avatar Oct 13 '20 07:10 palexdev

The class member List<String> parents has been defined in 5 files in Drive API. The method getParents() with return type List<String> has been defined in 15 files. The method setParents() with return type List<String> has been defined in 15 files.

Please check screenshots of these definitions from file.java

List<String> parents https://drive.google.com/file/d/149mkjvNvV6ghKRb7eYxZ7NG1OfaSHls4/view?usp=sharing List<String> getParents() https://drive.google.com/file/d/1KB3i1qSANTP8FOtzhIo82Gv6E141ZsNq/view?usp=sharing List<String> setParents() https://drive.google.com/file/d/1K1rQQy6gqAYNE2GcpDOhxuCl6yI6qNbb/view?usp=sharing

These API's could have been used in many Apps and changing the implementation on server side (changing return types, data member type) could lead to implementation changes in the Apps.

I think memory should not be a concern in this scenario as the API is going to return the same string in a list of size 1. Any memory usage increases due to List of size 1 could be optimized by Java Compiler.

About checking for null conditions, even if the data type of parents class member was string, there has to be a condition to check if the String is null.

So in conclusion i think that there does not have to be any changes on server side, just setting enforceSingleParent to True (in Drive.java) in API calls could be sufficient.

Hope this helps resolve the issue.

ganeshbch avatar Oct 13 '20 17:10 ganeshbch