farmOS / farmOS.py

A Python library for interacting with farmOS over API.
GNU General Public License v3.0
27 stars 12 forks source link

Accept an array of id's as a .get() parameter #14

Closed jgaehring closed 3 years ago

jgaehring commented 5 years ago

From farmOS/farmOS.js#7:

We'd like to be able to get logs (and potentially assets and areas, too), by passing in an array of id's (integers). Under the hood, this would format a query string in the format log.json?id[]=X&id[]=Y. An example: https://test.farmos.net/log.json?id[]=163&id[]=167 . The one limitation to this formatting is the URL string length, which shouldn't go over 2000 chars (see this SO post).

This would be useful in scenarios where a client has an arbitrary collection of certain logs, which can't be represented by a simple import filter, and wants to get updates on all of those logs from the server.

symbioquine commented 4 years ago

The "SO post" referenced above is https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers

paul121 commented 3 years ago

This can be accomplished using an id filter with multiple values in 1.x

In 2.x a single ID can be fetched using client.resource.get_id(). See #42 for more info on this change.