Action Modeling: Case Studies

link:

POST collections/entries/add
POST collections/entries/curate
POST collections/entries/move
POST collections/entries/remove
不曉得是不是因為實作的關係,它的新增或移除都表達在URI上;另外它並沒有提供HATEOAS的功能。

幾乎都使用controller resource來表達特別的流程,link:

# Uploads a channel banner image to YouTube.
POST /channelBanners/insert
# Expresses the caller's opinion that one or more comments should be flagged as spam.
POST /comments/markAsSpam
# Uploads a custom video thumbnail to YouTube and sets it for a video.
POST /thumbnails/set
# Add a like or dislike rating to a video or remove a rating from a video.
POST /videos/rate
# Retrieves the ratings that the authorized user gave to a list of specified videos.
GET /videos/getRating
# Report a video for containing abusive content.
POST /videos/reportAbuse
# Uploads a watermark image to YouTube and sets it for a channel.
POST /watermarks/set
# Deletes a channel's watermark image.
POST /watermarks/unset
insert的部分不曉得是考量什麼特別使用了controller resource,因為POST應該就能表達新增了;而getRating的部分,應可以是store resource,名稱為rating。

皆使用controller resource的形式,link:

# Subscribes to changes for a user.
POST  /changes/watch
# Subscribes to changes to a file
POST  /files/fileId/watch
# Stop watching resources through this channel
POST  /channels/stop
# Exports a Google Doc to the requested MIME type and returns the exported content.
GET  /files/fileId/export
但以export file來說,我會傾向於使用store resource並搭配Accept+Type:
Accept: text/plain
GET  /files/fileId/content

皆使用controller resource的形式,link:

# Copies a table.
POST  /tables/tableId/copy
# Imports more rows into a table.
POST  /tables/tableId/import
# Replaces rows of an existing table. 
POST  /tables/tableId/replace

皆使用controller resource的形式,link:

# Publishes a container version.
POST  /accounts/accountId/containers/containerId/versions/containerVersionId/publish
# Restores a Container Version. 
POST  /accounts/accountId/containers/containerId/versions/containerVersionId/restore
# Undeletes a container version.
POST  /accounts/accountId/containers/containerId/versions/containerVersionId/undelete

GitHub針對不同動作使用了不同方法,首先是store resource,link:

# issue擁有名為locked的屬性,type為boolean
# Lock an issue
PUT /repos/:owner/:repo/issues/:number/lock
#Unlock an issue
DELETE /repos/:owner/:repo/issues/:number/lock
link:
# Star a gist
PUT /gists/:id/star
# Unstar a gist
DELETE /gists/:id/star
# Check if a gist is starred
GET /gists/:id/star
這部分設計為store resource,但我不了解為何不做成controller resource,link:
# Merge a pull request (Merge Button)
PUT /repos/:owner/:repo/pulls/:number/merge
這裡把一筆merge當collection resource,所以是對merges做新增,link
# Perform a merge
POST /repos/:owner/:repo/merges

這裡的用法比較奇怪,因為lock也不是file的一個屬性,link:

# Lock 
PUT /files/file_id
{"lock": { "type": "lock","expires_at": "2015-12-12T10:55:30-08:00","is_download_prevented": false}}
# Unlock
{"lock": null}
使用controller resource,link
# Copy a file
POST https://api.box.com/2.0/files/file_id/copy
# Used to create a copy of a folder in another folder. The original version of the folder will not be altered.
POST https://api.box.com/2.0/folders/folder_id/copy
第一次看到OPTIONS的用法,用來檢查資源是否可存取,link:
# Preflight Check, The Pre-flight check API will verify that a file will be accepted by Box before you send all the bytes over the wire.
OPTIONS https://api.box.com/2.0/files/content
以lock與unlock來說,我會選擇設計為store resource:
# Lock 
PUT /files/file_id/lock
# Unlock
DELETE /files/file_id/lock