There's currently both targeted and non-targeted actions for resources, but the relationships are always targeted. There should probably be non-targeted relationships as well.

The non-targeted relations would enable GET-requests for url:s like resourcename/relationame. It's therefor important that if a resourceid would match a relationname that resourcename/relationame takes precedence over resourcename/relationid.

CommentFileSizeAuthor
#1 services-1042674.patch6.66 KBkylebrowning

Comments

kylebrowning’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
StatusFileSize
new6.66 KB

My initial patch is for 6.x mainly because we have all the tests for it.

This patch is not complete, but I want you guys to start reviewing it.

Things left to do
-Add actual non-targeted functions so you dont get 401 when accessing node/titles

kylebrowning’s picture

Status: Active » Needs review
gdd’s picture

I'm having a hard time figuring out what this buys us. Can someone come up with some concrete use cases that can't be solved much more easily using index? I know that the original issue (#987180: Don't allow GET-requests for resource actions in the REST server) was centered around nodeFiles which everyone (correctly) seemed to agree should be a targeted relationship on nodes. But is there really a use case for node/files where we retrieve them all?

voxpelli’s picture

@heyrocker: node/files probably don't have a use case - but there will probably be a situation where we have a resource that relates to another resource on the top level? And even if it won't - people will need this option to abuse in a non restful way or they will beg for top level actions to be exposed over get-calls.

@kylebrowning: Why change the existing relationships? It would be enough to add a new non-targeted one? So we avoid an API-change.

Some coding style feedback:

+++ b/servers/rest_server/includes/RESTServer.inc
@@ -537,6 +537,20 @@ class RESTServer {
+      if($method == 'GET') {

Missing a space here

+++ b/servers/rest_server/includes/RESTServer.inc
@@ -537,6 +537,20 @@ class RESTServer {
+          if($resource['relationships'][$path[0]]) {

Space missing here as well

marcingy’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Needs review » Postponed

Moving to current version and setting as postponed for consideration in 7.4

MrMaksimize’s picture

Hey guys,
I have an issue here that would definitely be considered a use case. Sometimes, people want APIs to be multi-level paths, and it looks like that would solve the problem. What do you think? http://drupal.org/node/1203222

ardnet’s picture

Hi MrMaksimize, what you meant is something like: {endpoint}/node/story/5
which mean that, get the content type story on page 5. Something like that, right?

I'm looking forward for that as well.

ardnet’s picture

-- sorry, double post --

didlix’s picture

Subscribe

kylebrowning’s picture

Status: Postponed » Closed (won't fix)