rlm_rest: Parse response from API?
Hi, my API returns something like: {"count":1,"next":null,"previous":null,"results":[{"id":16, ... How can I access key/value pairs in the "results" data structure and assign the value of a specific pair to an attribute? Mit freundlichen Grüßen, -- [*] sys4 AG https://sys4.de, +49 (89) 30 90 46 64 Schleißheimer Straße 26/MG,80333 München Sitz der Gesellschaft: München, Amtsgericht München: HRB 199263 Vorstand: Patrick Ben Koetter, Marc Schiffbauer, Wolfgang Stief Aufsichtsratsvorsitzender: Florian Kirstein
On Dec 18, 2021, at 10:27 AM, Michael Schwartzkopff <ms@sys4.de> wrote:
my API returns something like:
{"count":1,"next":null,"previous":null,"results":[{"id":16, ... How can I access key/value pairs in the "results" data structure and assign the value of a specific pair to an attribute?
It's hard to do in 3.0. :( v4 is more able to decode this. Matthew updated rlm_json in the v3.2.x branch. It can encode more json attributes, but can't decode any. We'd be OK with getting a patch to update 3.2. But if we change 3.0 at this time, then Matthew will be upset at me. :( Alan DeKok.
On 20.12.21 16:48, Alan DeKok wrote:
On Dec 18, 2021, at 10:27 AM, Michael Schwartzkopff <ms@sys4.de> wrote:
my API returns something like:
{"count":1,"next":null,"previous":null,"results":[{"id":16, ... How can I access key/value pairs in the "results" data structure and assign the value of a specific pair to an attribute? It's hard to do in 3.0. :( v4 is more able to decode this.
Matthew updated rlm_json in the v3.2.x branch. It can encode more json attributes, but can't decode any. We'd be OK with getting a patch to update 3.2. But if we change 3.0 at this time, then Matthew will be upset at me. :(
Alan DeKok.
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Thanks for the response. I solved the problem in rlm_python3. I write a blog article about this work, when I find the time. Basic idea: FreeRADIUS -> dynamic clients -> lookup in netbox asset management. Mit freundlichen Grüßen, -- [*] sys4 AG https://sys4.de, +49 (89) 30 90 46 64 Schleißheimer Straße 26/MG,80333 München Sitz der Gesellschaft: München, Amtsgericht München: HRB 199263 Vorstand: Patrick Ben Koetter, Marc Schiffbauer, Wolfgang Stief Aufsichtsratsvorsitzender: Florian Kirstein
On 20/12/2021 15:48, Alan DeKok wrote:
Matthew updated rlm_json in the v3.2.x branch. It can encode more json attributes, but can't decode any. We'd be OK with getting a patch to update 3.2. But if we change 3.0 at this time, then Matthew will be upset at me. :(
v3.0 is stable, v3.2 is new features :) Broken releases make me grumpy! The problem is that even with all the automated tests we've got, it's far too easy to break things even with small features. FreeRADIUS is too flexible for us to be able to test every possible configuration. If someone wants to backport the jpath stuff from v4 to v3.2 then that should allow pulling data out of JSON. Or use e.g. rlm_perl - but that will likely have a performance impact. But apart from security & bug fixes and documentation, we need to just leave v3.0 alone :-P -- Matthew
participants (3)
-
Alan DeKok -
Matthew Newton -
Michael Schwartzkopff