Re: RPC and REST

Michael J Rubinsky <[email protected]> Sat, 10 Feb 2018 17:00:14 +0000
Newsgroups gmane.comp.horde.devel
Message-ID <20180210170014.Horde.EMSKoX5myEAZihD6OSbtRsm@tarn.theupstairsroom.com>
Quoting Ralf Lang <[email protected]>:

> Am 17.10.2017 um 22:07 schrieb Ralf Lang:
>> Hallo,
>>
>> lately I have been examining the REST and RPC topics discussed in January.
>>
>> Bad news is it doesn't quite fit and I am not sure if it's a good  
>> idea to cram it into the RPC framework. It looks more and more like  
>> Rest should sit on top of the inter-app API, separate from RPC.
>>
>>
>> For example, let's have
>>
>> PUT /rpc/rest/admin/user/henry
>>
>> to create a new user "henry" (identity details and auth credentials  
>> random or undefined)
>>
>> /rpc/ (or /rpc.php) is our universal endpoint for all rpc-ish stuff.
>> /rpc/rest/ to discern rest from other users of the rpc endpoint  
>> (dav, phpgw, json-rpc, whatever)
>>
>> The existing RPC backends all have a clear and easy separation of  
>> api, command/method and parameters which can be mapped to the  
>> internal inter-app api and are happy to just return any scalar or  
>> array structure as the single result.
>>
>>
> Maybe it's more straight forward to do one thing at a time - provide  
> a minimal rest API now, assuming data is always scalars and arrays  
> (which it currently almost always is) and split/wrap inter-app from  
> external apis in a separate move. It's just getting too much for a  
> single change.
>
>> To make REST automatically fit into the existing RPC framework, it  
>> would require to limit it to a fixed /api/resource/$param/$param..  
>> format with resource and method defining the horde api method - and  
>> then we would need to create method names like admin.putUser("henry")
> No, these are already there - at least turba and kronolith have the  
> sync/DAV-oriented browse()/put()/delete() and friends. A minimum  
> rest api could translate this to get/put/post on the app's primary  
> collection (calendar, addressbook) and item event, contact) types.
>
> For the proposed admin/ api, collections would be user(s), group(s),  
> permission(s)
>
> Is there any english language pluralization on any horde groupware  
> items that does not pluralize by adding "s"?

Nope. At least not that I see going through the app list....



>> We can make this more straight forward if every resource is its own api
>>
>> user.put("henry") -> PUT /rpc/rest/user/henry
>>
>> Of course, allowing for named parameters would make this more  
>> versatile but registry->call does not have named parameters.
>>
>> Still, methods like put and get instead of create/list don't blend  
>> well with the rest of rpc methods.
>>
>> Bottom line is:
>>
>> It might make sense to have rpc.php as the common endpoint for  
>> everything (dav, json-rpc, rest).
>>
>> It might also make sense to have both RPC and REST wrap the bare  
>> inter-app API into something providing more context on allowed,  
>> required and optional parameters (and formats, auth / no auth,  
>> limiting...) but I do not see any way to make REST feel right as  
>> yet another Rpc driver interfacing the same set of remote execution  
>> methods. At least not without yet another wrapping layer to be  
>> coded for each exposed resource.
>>
>>
>> Apart from that, Horde_Rpc has some limitations I looked into:
>>
>> It's implicitly assuming to have a horde registry global variable  
>> around to provide Api Methods (see Horde_Rpc_Xmlrpc) line 34
>>
>> It's not allowing any parameter to override this
>>
>> The specific class factory is part of the base class
>>
>> No way to ensure methods for Horde inter-app communication and  
>> external Apis can be separated
>>
>> Authentication and Authorization is not really separated from the modules
>>
>> For example, some reading calls may make sense to expose to the  
>> unauthenticated public, others should only be available to  
>> authenticated users, to admins or to users with a specific horde  
>> permission.
>>
>> Inter-App calls should be able to yield PHP Objects, but the Rpc  
>> modules are currently not fit to auto-convert them into arrays and  
>> scalars for serialization to external interfaces
>>
>> If an app has two apis, currently all methods show up for both  
>> apis. Separate per api classes instead of one monolithic Api.php  
>> per app may help.
>>
>> I'd like to go for separate per action classes but this creates  
>> problems with implementing listMethods, unless I explicitly declare  
>> them in registry.php or in said per api class.
>>
>> Separate the api provider (list of valid methods) from the Rpc  
>> backends (ship a dummy provider with Horde_Rpc, ship the  
>> horde-specific provider with Horde_Core)
>>
>> Separate the authentication provider from the Rpc backends (for  
>> now, AuthHorde, AuthSeparate and Null should be sufficient)
>
> -- 
> dev mailing list
> Frequently Asked Questions: http://wiki.horde.org/FAQ
> To unsubscribe, mail: [email protected]



-- 
mike
The Horde Project
http://www.horde.org
https://www.facebook.com/hordeproject
https://www.twitter.com/hordeproject

-- 
dev mailing list
Frequently Asked Questions: http://wiki.horde.org/FAQ
To unsubscribe, mail: [email protected]
(unnamed) (application/pgp-keys, 9.1 KB) - not displayed
signature.asc (application/pgp-signature, 821 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4

iQIcBAABAgAGBQJafyUeAAoJEJGSgkbRsxbbF9oP/08H2rLBAUQL2xoLhyJ1yXSE
ZjzmN/hmlf2kQ8Xr2u5ul0WicVfX0B3Q0P+Ncm1ZchPmvYminDeoGWT7wDMe+RO8
5GkNBrPtkGoYl+PrPRMGQw+2SJv0QG+J5tzdNFOtFAQhVB6J5DVp8KRS3V5dUBLL
cfe5Xe+5HBo034aF+yQh+DuWmD0s8tHg/1Ht1NYPphZkhGE2LYTfiMyHS/8a+Kyc
13TUYDR+drRYLEc7CCx3yybud7qpdB+iNifC5TrF+/+gu8c+U87SZL1xj7fXowNC
9m3rm31jbPahHpWWwkIdDIXehCSaS0s6Ne54T5ty+MVlmZZ6GR0anTPsWzZLDaOS
j7fRh6ksueqKC/EVoCQx7oHZn7G5+bVdPEoOQXuZNv/YiZHpbW7i0IowwDtpJgGX
PGrCcmYQ2/Eazm34SusSkpVB/AzPjOptPQx3ELpsjp8svdKBUqPkkQKWnOb9Ml2H
cWSnWAzjfxZSKjbd+CxCaEIG1cplMMe1CHE4qpdznv9rxkHjUlQs3FxB3M7g1SwF
E+zYxSzRf9a15ddET4bwdgCIhunUjcRf5TYZn+OeRM7P7+r9LbPIQlU5QlRxIY9I
Qyq2BKTOSViRnmCtbNwADbAqZBsLw1oMU7cOLwjz2f5qbklWjoDJvdZj2vTSVj3k
c5Hqg4izq1NJktupYY58
=zwt/
-----END PGP SIGNATURE-----