Closed strix-technica closed 6 years ago
@jmvedrine, you might be interested in this PR — especially if you plan to do any significant development of your own.
Thanks for the thumbs-up, @Timx85!
@rcastberg is a bit preoccupied with other stuff right now so I don't know when he might be able to deal with this PR. I don't know if it's possible to issue a PR against a different fork, but you each can manually merge these changes via the git command line if you want (ask if you need any pointers).
N/m, it is now merged so do update your forks. The REST API has changed a bit and I haven't updated the requests accordingly (yet), and if the old-style requests quit working you'll need to pull/merge to get the updates.
Good luck, and I hope this is of some use!
This is a substantial rewrite with two objectives in mind: to make as few back-end REST requests as possible (which is crucial in terms of avoiding sanctions against your account for abuse of Sure's infrastructure) and to make the API better-suited to programmatic applications.
A number of feature enhancements and additions have also been made. The principal contributions of this PR are:
SurePetFlapAPI
) and separate query class (SurePetFlapMixin
) query interface.SurePetFlap
is the combination of the two, but users can create their own query mixins if they wish.print_timeline()
method.The code in this PR is not 100% backwards compatible. One or two methods have been renamed, but chances are not ones you may use directly.
The main change required by any user of this API is to enclose calls to any of the update methods inside
with ...:
context block. When the block exits, the cache is flushed back to disc. The cache is only locked for the duration of the context block, so you can query it as much as you like from as many instances as you like provided only one instance at any one time is performing an update. Example: