google-api-java-client-services
google-api-java-client-services copied to clipboard
Question: Switched to single-parent model, will the library be updated?
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
This repository contains over 100 client libraries. Which client and endpoint are you referring to?
Oh right sorry, I'm referring to the drive api
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.
@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
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.