Using the following API allows you to obtain multiple properties assigned to a file:
props = service.properties().list(fileId=fileId).execute().get('items', [])
However, I don't see any way to set multiple properties. Is this just missing from the documentation, or have Google really overlooked this?
Think of properties as a list, rather than a map. So the answer is no.
To save http traffic you could batch your requests as described here https://code.google.com/p/google-api-java-client/wiki/Batch
Related
I have recently started developing an application to analyse my all-time exercises in the Polar platform.
I'm using their Accesslink API to get new sessions and I have exported my old sessions through another service they offer.
The exported sessions come with fully detailed information (instant GPS location, speed, heart rate), but the JSON data provided by the API is just a summary. I am looking for a way to get the initial position (GPS location) of my session to, later, find the city's name from another source. I think that the only way to do this is by getting the GPS info of my sessions.
Although the sessions have a has-route field, I cannot find in their documentation a way to request this route. They have provided a working example, but it does not provide a way to get these data.
Does anyway know if this is possible and, if so, could you please give me some directions?
Thanks in advance.
Turns out that the GPS information is provided through GPX files, which are provided by the API mentioned on the question. There is a method implemented to do this on their github (link also on the question) which already performs this task. I have added the call to this method and saved its output in this project.
I am using drive api v3 to look for files I hare shared with others (anyone),to list them & potentially cancel sharing them.
I know that in the search box you can do a 'to:' and it will retrieve these files, but I could not use such thing on the API.
my current tri ;
query="'me' in owners and trashed=false and not mimeType = 'application/vnd.google-apps.folder' and visibility != 'limited'"
Thanks in advance
As tanaike said, a workaround that solves the problem is by looping through the files using files.list() function, and including id, owners, permissions in the fields. This is going to return a list of objects, and from there we can check if type is anyone.
From there, we can also check for attributes like shared:true & ownedByMe:true.
This is just a workaround, and surely not the best solution, since with Drive search, we can do all this by typing to:, which lists all owr shared files. I hope we get an API for this.
Thanks again tanaike
I'm attempting to programmatically register Service Principals in Azure AD using Python. It looks like I should be using the ServicePrincipalsOperations class, however the documentation does not clearly outline what is needed for the parameters. It appears that it is expecting data from other classes within azure.graphrbac, but the documentation is unclear.
I think I should be using the azure.graphrbac.GraphRbacManagementClient to generate the client parameter for ServicePrincipalsOperations, but that's just a guess at this point.
Similarly, I suspect that I would need to use azure.graphrbac.models.ServicePrincipalCreateParameters for the config parameter.
Has anyone successfully registered a Service Principal using Python that may be able to shed more light on these parameters?
Thanks in advance!
So you can use this test as a reference, but the documents do specify what you need to pass in to the method to create a service principal.
Sample code:
self.graphrbac_client.service_principals.create({
'app_id': app.app_id, # Do NOT use app.object_id
'account_enabled': False
})
More reading: Create service principal programmatically in Azure Python API
I've been working on an AppEngine-based project and I wanted to know if it's possible to ignore a ProtoRPC message field.
With the Java SDK, you can use #ApiResourceProperty to ignore a property (this means it's not contained within the response returned to the browser). However, I have not come across a way of doing this using the Python SDK.
Is there anything like this in the Python SDK?
Thanks, Adil
Nope, unfortunately not (at least not to my knowledge).
Two possible solutions depending on your use-case.
Set field values to None before returning the message in your method. That way they will be skipped/not included in the JSON response.
If your messages are hooked up to datastore models you can use the endpoints-proto-datastore library which allows you to use your ndb models directly in your API methods. Additionally it allows for request_fields and response_fields parameters in the method decorator which will limit the request or response to the specified subset of message/model fields. (internally it creates the necessary message classes for you)
I am writing an app in which users will be able to store information that they can specify a REST interface for. IE, store a list of products at /<username>/rest/products. Since the URLs are obviously not known before hand, I was trying to think of the best way to implement dynamic URL creation in Flask. The first way I thought of would be to write a catch-all rule, and route the URL from there. But then I am basically duplicating URL routing capabilities when Flask already has them built-in. So, I was wondering if it would be a bad idea to use .add_url_rule() (docs here, scroll down a bit) to attach them directly to the app. Is there a specific reason this shouldn't be done?
Every time you execute add_url_rule() the internal routing remaps the URL map. This is neither threadsafe nor fast. I right now don't understand why you need user specific URL rules to be honest. It kinda sounds like you actually want user specific applications mounted?
Maybe this is helpful: http://flask.pocoo.org/docs/patterns/appdispatch/
I have had similar requirement for my application where each endpoint /<SOMEID>/rest/other for given SOMEID should be bounded to a different function. One way to achieve this is keeping a lookup dictionary where values are the function that handle the specific SOMEID. For example take a look at this snippet:
func_look_up_dict = {...}
#app.route('<SOMEID>/rest/other', methods=['GET'])
def multiple_func_router_endpoint(SOMEID):
if SOMEID in func_look_up_dict.keys():
return jsonify({'result' = func_look_up_dict[SOMEID]()}), 200
else:
return jsonify({'result'='unknown', 'reason'='invalid id in url'}), 404
so for this care you don't really need to "dynamically" add url rules, but rather use a url rule with parameter and handle the various cases withing a single function. Another thing to consider is to really think about the use case of such URL endpoint. If <username> is a parameter that needs to be passed in, why not to use a url rule such as /rest/product/<username> or pass it in as an argument in the GET request?
Hope that helps.