Search for Google Drive files based on new properties resource - google-drive-api

Google just introduced a new feature in Google Drive SDK which is the ability to set properties to files, as key/value pairs.
According to the blog post on Google Developers blog we can use these properties as searchable fields. However I cannot see in the documentation how to search for files using these properties.
For example: retrieve all files where property A has the value X.
I know the feature is brand new but I could really make use of this in my current project. Have I missed anything ?

Well I find, its possible to search on drive based on properties param.
Check doc. https://developers.google.com/drive/web/search-parameters
Code Snippet :
resp = newDriveService.files().list(q="properties has { key='customKeyA' and value='customKeyAValue2' and visibility='PUBLIC' }").execute()
Note : you have to specify all 3 params viz. key, value and visibility while searching. If you don't use it will throw Invalid Params exception.

Unfortunately, we don't currently support this. This is currently a high priority for Google and they are working on it. Stay tuned.

Related

Export Map Style from Google Maps Platform

Google have decided to replace their Map Style tool with the Cloud-base Maps Styling.
The new Beta tool allows you to import JSON map styling, but it provides no way of exporting a map style created with the Beta tool.
A colleague of mine has created a custom Map Style, but now we need to copy it into another project, but there appears no way to do this. We can duplicate the style, but only into the same project.
Is there any way around this, eg. a GCP console command.
I've tried inspecting the network traffic to see if I can grab the config, but it's in a completely different format that can't be exported.
Edit: It may appear I've done no research on this question, but the fact is that because it's referring to a Beta GCP tool, there is very little information available on its use other than:
A blog post
A sidebar which concentrates on the publishing side
All the Maps API docs refer to using a Map ID, which isn't the problem here.
Another Edit:I've created an feature request, in case anyone is interested...

Location of a comment in its corresponding Google doc

Given a google doc retrieved through the Google docs API and its comments retrived with the Drive API,
How do you know where in the document a comment corresponds?
I've been inspecting all the fields and couldn't find a relation except the quotedFileContent that contains the commented text in the doc, but this would resolve ambiguously if that text is duplicated.
You cannot retrieve the location of a comment using Drive API.
As you can see in the official documentation, the Comment resource has an anchor field that provides information on the region of the document. Nevertheless, if you use the API to get information about a comment, you will see that the anchor field in the response is actually a string identifier composed of a kix prefix and a certain anchor ID as a suffix, which don't really give you an idea of where the comment is located.
The problem is not just about retrieving the locations to which a comment is anchored, but also about creating anchored comments in a desired location using the API, as you can see here.
Basically, as it is currently implemented, this anchor tool is meant for third-party integrations to use this API to specify their own custom anchor data.
There are several open cases in Issue Tracker related to this:
https://issuetracker.google.com/issues/36756056
https://issuetracker.google.com/issues/36763384
Reference:
https://developers.google.com/drive/api/v3/manage-comments
https://www.youtube.com/watch?v=ZBU52nacbLw

Google Drive API get only one property

I'm using the Google Drive API V3 to get custom properties from alot of files.
I only need one property out of the properties collection. Is it possible to set the fields attribute so i can only get the one property?
Thank you in advance!
fields is part of the Standard Query Parameters valid for all of the Google discovery apis.
fields Selector specifying a subset of fields to include in the
response. For more information, see the partial response section in
the Performance Tips document. Use for better performance.
Yes you can specify fields.

Associate and Search on a document metadata using Google Drive APIs

Is there a way I can have my own metadata associated to a document that I am uploading to Google Drive? If yes, how do I mention that metadata in the API?
Also, can I perform a search using the metadata using the APIs. Say if there are 3 documents with the metadata tag as 'cooking' ... can I use the search API where I send the tag 'cooking' as a search query and I get a list of all the docs associated with that metadata.
Regards, Saurabh
Yes, see custom file properties. https://developers.google.com/drive/web/properties
To search for custom file properties, add this to your search parameters:
properties has { key = 'foo' and value = 'bar' and visibility = 'private'}
Note that all 3 parts are required.

When using the Google Places API, what is the difference between "using the JavaScript library" and "calling the API directly"?

I have seen the two forms of reference to the Google Places Library/Service, using JavaScript vs calling the API directly, a number of times, but I don't understand the difference. The Google Docs don't describe anything about two methods of accessing the API.
For example, this question talks about 2 ways of accessing the API: OVER_QUERY_LIMIT in a loop
And it appears that there is some type of direct web access taking place in this question: Querying Google Places API using jQuery
Is this something where there was an old way that involved formatting URL parameters and the new way is by utilizing the JavaScript library calls?
FINAL SUMMARY EDIT: There are two distinct ways of requesting data from Google, as described in #Dan Nissenbaum's answer below. And since my original question, the QUERY_LIMIT question referenced above has been edited to also include more information about the two options.
Perhaps you are referring to the distinction between the Google Places API that is intended for use on the SERVER (i.e., utilizing PHP to call the Google Places API directly), and using the completely different approach of the Google Places Javascript Library in which the BROWSER executes Javascript using the Javascript library provided by Google (that internally wraps calls to the Google Places API, so that you, as a Javascript programmer, only need to understand the Javascript library provided by Google, and use that)?
Here are the two scenarios.
Scenario #1: Use the API directly. For this method, you must refer to Google's API documentation for the Google Places API: https://developers.google.com/maps/documentation/places/.
Using this API works as follows (giving a simple example only). Say you want to retrieve places within 1000 meters of latitude=-27.2531166, longitude=138.8655664. You need to hit a URL as described by the API documentation: https://developers.google.com/maps/documentation/places/#PlaceSearchRequests.
In this example, the URL looks like this (it's long):
https://maps.googleapis.com/maps/api/place/search/json?location=-27.2531166,138.8655664&radius=1000&sensor=false&key=AddYourOwnKeyHere
You need a key for your personal use, which I assume you have. There are other options you can specify, such as limiting the results to restaurants, etc.
When you hit this URL, the data will be returned in either JSON, or XML format, as specified by the text json in the URL above (use the text xml for xml). This data is returned exactly like data is returned from any URL call when you hit a URL in your browser.
You can test this by simply typing the URL directly in your browser, and see the results.
To use the API directly from code, you will need to use code that hits the external URL above within code and retrieves the results within code (for example, using the PHP CURL library, or using AJAX in Javascript).
Scenario #2: You use the Javascript library that Google provides that wraps the API, so you don't need to deal with it. I'll update the answer with more details about this, if you don't know what this is.
The docs do discuss the two different approaches. The Places Library utilizes the Google Places services from within the JavaScript Google Maps API. If you are using the Google Maps API in a browser, this is probably the approach for you:
https://developers.google.com/maps/documentation/javascript/places
There is also a web service, which allows you to query directly from your application. You query it using direct http calls to Google services. If you need access to the data on your server or a mobile device, this is the approach you want to take:
https://developers.google.com/maps/documentation/places