Closed paul121 closed 3 years ago
This also has some implications for the Aggregator URL endpoints. I think we need to implement the type
as either path parameters or query parameters
I think we should consider removing the bundle parameter from client.resource.* methods and instead only accept a type parameter which is assumed to be correctly formatted.
Don't think we'll go this route. I don't love that the JSONAPI responses return a type
that isn't compatible with the farmOS.py methods, but I think that requiring a JSON API formatted type string would be worse DX. The aggregator resource
endpoint will have path parameters for the type
and bundle
too.
This means that custom code parsing a JSON API response might need to parse a resource's type
(eg: log--activity
) into separate log
and activity
strings itself.
As @mstenta summarized in #39:
This is particularly important in determining the arguments for the farmOS client methods. Right now the farmOS.py
client.resouce.*
methods have separate parameters fortype
andbundle
:client.resource.get(type, bundle, filters)
. Methods for logs, assets and terms only require a bundle to be provided:client.log.get(bundle, filters)
.This is an important DX consideration because the
type
strings found in a JSONAPI response, such aslog--observation
, cannot be passed as the first argument toclient.log.get(bundle, filters)
. Similarly, theuser--user
identifier cannot be passed as either the first OR second parameter ofclient.resource.get(type, bundle, filter)
.Proposed resolution
I think we should consider removing the
bundle
parameter fromclient.resource.*
methods and instead only accept atype
parameter which is assumed to be correctly formatted. The helpers for logs, assets, and terms could continue to use abundle
param, with the limitation that a fulltype
string cannot be provided to these methods.I know @jgaehring is implementing the
type
as a specialfilter
since farmOS.js will have the ability to request ALL log types if none are provided. We could do the same for the log, asset and term helper methods, but I'm hesitant. If we don't implement the "request ALL types" functionality, then it becomes required input, which is better implemented as a method parameter IMO.