How to calm the resources of related parents and children?

I am developing an api, and I would like users and groups to save searches, but I do not know how to best expose this information. I came up with several URIs to expose them:

# These are for CRUD the search definitions, not running the searches
1. /users/{username}/searches # lists the searches for a user
2. /users/{username}/searches/{search-name} # CRUD a specific user search
3. /groups/{groupname}/searches # lists the searches for a group
4. /groups/{groupname}/searches/{search-name} # CRUD a specific group search
5. /searches/{search-id|search-name}
6. /searches/group/{groupname}/{search-name}
7. /searches/user/{username}/{search-name}

I do not consider it the right to expose all these URIs. This means that there are two ways to update or search the list for the user and group: through / groups / search or through / search / group. It also means more support, and I'm afraid that subtle differences will develop.

Distortions can be independent entries in the database and are not tied to a specific user or group (for example, the default system search or context-sensitive queries).

Since searches can be independent, they feel that they cannot expose them as /users/searcheswell /groups/searches. At the same time, if I think, "What is a bean search?" I would first think about /users/bob/searches, because, logically, searching for his bob. Similarly, if I want to, say, create a backup bob account, all of his personal information must be under / users / bob.

So, does anyone have any advice on which path is preferred and / or worked well (or bad) for them?

+3
source share
3 answers

I would like to stick

5. /searches/{search-id|search-name}
6. /searches/group/{groupname}/{search-name}
7. /searches/user/{username}/{search-name}

The backup problem can be solved by creating a new resource that contains links to Bob information in the system, for example.

GET /AccountData/Bob

<div class="AccountData">
   <link rel="searches" href="/Searches/User/Bob"/>
   <link rel="options" href="/Options/User/Bob"/>
   <link rel="usagehistory" href="/History/User/Bob"/>
</div>

, , , . . Wikis , .

, .

.

GET /Groups/{GroupName}

<div class="group">
  <div class="name">AGroup</div>
  <link rel="searches" href="/Searches/Group/AGroup"/>
</div>

URL.

API REST ( )

, , , SO , URL- RESTful API, , .

P.S. , HTML - , , XML.

+3

, (, - ). . /searchlist? user = john. , .

0

- , . URI ,

/users/{username}?q={query string}
/groups/{groupname}?q={query string}

2

 "RQL" (Resource Query Language)

"FIQL" (Feed Item Query Language)
0
source

Source: https://habr.com/ru/post/1703793/


All Articles