Open liuxiran opened 3 years ago
cc @nic-chen @starsz @imjoey @bzp2010 @spacewander @membphis @moonming @juzhiyuan to have a look when you have time, thanks a lot
Others LGTM, but why not keep the PUT
API?
Others LGTM, but why not keep the
PUT
API?
I tend to guide the user to complete a target operation using the specified API, without ambiguity @nic-chen
For create, we can use POST
, for update, we can use PATCH
,
As our doc says, PUT
API is used to create a route by ID, ID
is used as a unique identifier and would ideally be better generated by default. And on the other hand, it can also update the already existed route, and if we want to update route, PATCH
would be more flexible to use.
Hi, @liuxiran Thank you very much. After reading the proposal. I have some problems as follows.
put
method since we have the situation that specified the route ID.delete
method should return the deleted route info?Hi all, in order to make it more clear about what are the changes between the new design and the current manager-api admin-api, I made more detailed comparison:
this is the comparison of current Manager-API and Admin-API, we can see that the method and url are almost the same, only one exception, Manager-API has a API to check is the route name is exist, actually this is only a logic in UI, and in our APISIX only route id is the unique Identification, we allow repeated names, so it would be better to remove this API and the Validation rules.
the new design of route API is:
differences are:
PUT /apisix/admin/routes/{id}
, the reason comment here: https://github.com/apache/apisix-dashboard/issues/2105#issuecomment-909758567PATCH /apisix/admin/routes/{id}/{path}
to PUT /apisix/admin/routes/{id}/{path}
, the reason: when user use this API they can easier update the whole specified path in the route, refer to https://en.wikipedia.org/wiki/Patch_verb, PUT
method is more suitable.here is the comparison of the new design and the current Admin-API(Manager-API should the same parameters with Admin-API)
differences are:
uris
, remove uri
, since uris
contains uri
, there is no need to keep two of them to Increase the difficulty of choice for usershosts
, remove host
, same reason with beforeremote_addrs
, remove remote_addr
, same reason with beforeactually the response parameters struct is different between the Admin-API and Manager-API, here is the comparison,
and here is the new design as we talked about in the mail list
- I think we should keep the
put
method since we have the situation that specified the route ID.
I am actually hesitant here, the fact that the ID is our unique identifier, customization increases flexibility while inviting the risk of duplication, In case the user defines two routes with duplicate IDs, using the PUT method, the latter will override the former. if I've missed any details, please point them out @starsz
- The
delete
method should return the deleted route info?
Other APIs were referenced during the design process
Probably for application scenarios, I prefer to keep these return values
- We will return the route info directly rather than including it in a field?
For the get list API, info will be included in a field called items
, but for the info API, IMO we mainly want to get the route info, return them directly is a better way, what do you think?
Hi @starsz @nic-chen any updates?
Hi @liuxiran, sorry for the late reply.
In case the user defines two routes with duplicate IDs, using the PUT method, the latter will override the former. if I've missed any details, please point them out
It's right, this may be another way that is called update
.
kubesphere API does This is a special API IMO, if you look at others like,they don't return the delete info:
https://kubesphere.io/api/kubesphere/#operation/DeleteGroup https://kubesphere.io/api/kubesphere/#operation/DeleteNamespace https://kubesphere.io/api/kubesphere/#operation/DeleteClusterRole https://kubesphere.io/api/kubesphere/#operation/DeleteGlobalRole https://kubesphere.io/api/kubesphere/#operation/DeleteClusterRole
IMO we mainly want to get the route info, return them directly is a better way
It's not a good way. Please refer to other API docs like github, kubesphere, etc.
It's not a good way. Please refer to other API docs like github, kubesphere, etc.
Got you, thanks for the detailed examples, @starsz then for the delete API, just return HTTP code 200 is enough
This issue has been marked as stale due to 30 days of inactivity. It will be closed in 2 weeks if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the dev@apisix.apache.org list. Thank you for your contributions.
any update? @liuxiran
Hi, community. My understanding, is this proposal to convert the manager-api into an adminapi?
Yes, will continue this proposal in V3.
Route restful API proposal
According to our discussion on mail list: https://lists.apache.org/thread.html/r29f4b901d9779349bfcc3516f8f15ad73506bc16c3c3600666cbf7ef%40%3Cdev.apisix.apache.org%3E
I tried to list the entire Route module API in detail, and the goal is to serve as a sample of modifications to other modules, here they are:
Create route
Method and URL
Request parameters
and other request body parameters, please refer to https://github.com/apache/apisix/blob/master/docs/en/latest/admin-api.md#request-body-parameters
notice
uris
, removeuri
, sinceuris
containsuri
, there is no need to keep two of them to Increase the difficulty of choice for usershosts
, removehost
, same reason with beforeremote_addrs
, removeremote_addr
, same reason with beforecreate_time
andupdate_time
from the requestPOST
method to create a route, removePUT
(PUT /apisix/admin/routes/{id}
) to reduce the difficulty of choice for usersResponse parameters
return the new created route info
Fetch routes list
Method and URL
Request parameters
1
for enabled,0
for disable。notice this part has two changes:
label
tolabels
, forlabels
is the field name, and we support searching route with multi labels.Authorization
toX-API-KEY
to achieve the authentication.Response parameters
Get route info
Method and URL
Request parameters
Response parameters
Update route info
Method and URL
Request parameters
and other request body parameters, please refer to https://github.com/apache/apisix/blob/master/docs/en/latest/admin-api.md#request-body-parameters, and the same notice with create route
Response parameters
return the updated route info
Delete route
Method and URL
Request parameters
Response parameters
Update specify property
Method and URL
notice
PUT
method instead ofPATCH
, reason: this API aimed to update the specify property avoid entering the entire parameter structure in the body, and can only update the property defined in path parameters, soPUT
is more suitable.Request parameters
and the specify property values.
Response parameters
return the updated route info