#1132 REST API
This commit is contained in:
parent
de3d262965
commit
ff29ca0cf8
@ -9,7 +9,7 @@ Changelog for Redmine DMSF
|
|||||||
REST API
|
REST API
|
||||||
Entries operation (copy, move, download, delete)
|
Entries operation (copy, move, download, delete)
|
||||||
|
|
||||||
IMPORTANT: REST API for copying/moving has changed.
|
IMPORTANT: REST API for copying/moving has changed. Check *extra/api/api_client.sh*.
|
||||||
|
|
||||||
3.1.2 *2023-08-23*
|
3.1.2 *2023-08-23*
|
||||||
------------------
|
------------------
|
||||||
|
|||||||
@ -38,6 +38,7 @@ Features
|
|||||||
* Documents attachable to issues
|
* Documents attachable to issues
|
||||||
* Office documents are displayed inline
|
* Office documents are displayed inline
|
||||||
* Editing of office documents
|
* Editing of office documents
|
||||||
|
* REST API
|
||||||
* Compatible with Redmine 5.0.x
|
* Compatible with Redmine 5.0.x
|
||||||
|
|
||||||
Dependencies
|
Dependencies
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
# Authentication as input parameters either as login + password or the API key
|
# Authentication as input parameters either as login + password or the API key
|
||||||
#USER_LOGIN="${1}"
|
#USER_LOGIN="${1}"
|
||||||
#USER_PASSWORD="${2}"
|
#USER_PASSWORD="${2}"
|
||||||
#USER_API_KEY="${1}"
|
USER_API_KEY="${1}"
|
||||||
|
|
||||||
# BOTH XML and JSON formats are supported.
|
# BOTH XML and JSON formats are supported.
|
||||||
# Just replace .xml with .json
|
# Just replace .xml with .json
|
||||||
@ -44,25 +44,29 @@
|
|||||||
# 4. Create a new revision
|
# 4. Create a new revision
|
||||||
#curl -v -H "Content-Type: application/xml" -X POST --data "@revision.xml" -u ${USER_LOGIN}:${USER_PASSWORD} http://localhost:3000/dmsf/files/232565/revision/create.xml
|
#curl -v -H "Content-Type: application/xml" -X POST --data "@revision.xml" -u ${USER_LOGIN}:${USER_PASSWORD} http://localhost:3000/dmsf/files/232565/revision/create.xml
|
||||||
|
|
||||||
# 5. Copy document(s)
|
# 5. Entries operation
|
||||||
|
# 5.1 Copy document(s)/folder(s)
|
||||||
#curl -v -H "Content-Type: application/xml" -X POST --data "@entries.xml" -H "X-Redmine-API-Key: ${USER_API_KEY}" "http://localhost:3000/projects/3342/dmsf/entries.xml?ids[]=file-254566©_entries=true"
|
#curl -v -H "Content-Type: application/xml" -X POST --data "@entries.xml" -H "X-Redmine-API-Key: ${USER_API_KEY}" "http://localhost:3000/projects/3342/dmsf/entries.xml?ids[]=file-254566©_entries=true"
|
||||||
|
# 5.2 Move document(s)/folder(s)
|
||||||
# 6. Move document(s)
|
|
||||||
#curl -v -H "Content-Type: application/xml" -X POST --data "@entries.xml" -H "X-Redmine-API-Key: ${USER_API_KEY}" "http://localhost:3000/projects/3342/dmsf/entries.xml?ids[]=file-254566&move_entries=true"
|
#curl -v -H "Content-Type: application/xml" -X POST --data "@entries.xml" -H "X-Redmine-API-Key: ${USER_API_KEY}" "http://localhost:3000/projects/3342/dmsf/entries.xml?ids[]=file-254566&move_entries=true"
|
||||||
|
# 5.3 Download document(x)/folders(s)
|
||||||
|
#curl -v -H "Content-Type: application/octet-stream" -X POST --data "" -H "X-Redmine-API-Key: ${USER_API_KEY}" http://localhost:3000/projects/3342/dmsf/entries.xml?ids[]=file-254566
|
||||||
|
# 5.4 Delete document(x)/folder(s)
|
||||||
|
#curl -v -H "Content-Type: application/xml" -X POST --data "" -H "X-Redmine-API-Key: ${USER_API_KEY}" "http://localhost:3000/projects/3342/dmsf/entries.xml?ids[]=file-254566&delete_entries=true"
|
||||||
|
|
||||||
# 7. Delete a document
|
# 6. Delete a document
|
||||||
# a) Move to trash only
|
# a) Move to trash only
|
||||||
# curl -v -H "Content-Type: application/xml" -X DELETE -u ${USER_LOGIN}:${USER_PASSWORD} http://localhost:3000/dmsf/files/196118.xml
|
# curl -v -H "Content-Type: application/xml" -X DELETE -u ${USER_LOGIN}:${USER_PASSWORD} http://localhost:3000/dmsf/files/196118.xml
|
||||||
# b) Delete permanently
|
# b) Delete permanently
|
||||||
# curl -v -H "Content-Type: application/xml" -X DELETE -u ${USER_LOGIN}:${USER_PASSWORD} http://localhost:3000/dmsf/files/196118.xml?commit=yes"
|
# curl -v -H "Content-Type: application/xml" -X DELETE -u ${USER_LOGIN}:${USER_PASSWORD} http://localhost:3000/dmsf/files/196118.xml?commit=yes"
|
||||||
|
|
||||||
# 8. Create a folder
|
# 7. Create a folder
|
||||||
#curl -v -H "Content-Type: application/xml" -X POST --data "@folder.xml" -u ${USER_LOGIN}:${USER_PASSWORD} http://localhost:3000/projects/12/dmsf/create.xml
|
#curl -v -H "Content-Type: application/xml" -X POST --data "@folder.xml" -u ${USER_LOGIN}:${USER_PASSWORD} http://localhost:3000/projects/12/dmsf/create.xml
|
||||||
|
|
||||||
# 9. List folder content & check folder existence (by folder title)
|
# 8. List folder content & check folder existence (by folder title)
|
||||||
# curl -v -H "Content-Type: application/json" -X GET -H "X-Redmine-API-Key: ${USERS_API_KEY}" http://localhost:3000/projects/1/dmsf.json?folder_title=Updated%20title
|
# curl -v -H "Content-Type: application/json" -X GET -H "X-Redmine-API-Key: ${USERS_API_KEY}" http://localhost:3000/projects/1/dmsf.json?folder_title=Updated%20title
|
||||||
|
|
||||||
# 10. List folder content & check folder existence (by folder id)
|
# 9. List folder content & check folder existence (by folder id)
|
||||||
# curl -v -H "Content-Type: application/json" -X GET -H "X-Redmine-API-Key: ${USERS_API_KEY}" http://localhost:3000/projects/1/dmsf.json?folder_id=3
|
# curl -v -H "Content-Type: application/json" -X GET -H "X-Redmine-API-Key: ${USERS_API_KEY}" http://localhost:3000/projects/1/dmsf.json?folder_id=3
|
||||||
# both returns 404 not found, or json with following structure:
|
# both returns 404 not found, or json with following structure:
|
||||||
# {
|
# {
|
||||||
@ -74,7 +78,7 @@
|
|||||||
# }
|
# }
|
||||||
#}
|
#}
|
||||||
|
|
||||||
# 11. Update a folder
|
# 10. Update a folder
|
||||||
# curl -v -H "Content-Type: application/json" -X POST --data "@update-folder-payload.json" -H "X-Redmine-API-Key: ${USERS_API_KEY}" http://localhost:3000//projects/#{project_id}/dmsf/save.json?folder_id=#{folder_id}
|
# curl -v -H "Content-Type: application/json" -X POST --data "@update-folder-payload.json" -H "X-Redmine-API-Key: ${USERS_API_KEY}" http://localhost:3000//projects/#{project_id}/dmsf/save.json?folder_id=#{folder_id}
|
||||||
|
|
||||||
# update-folder-payload.json
|
# update-folder-payload.json
|
||||||
@ -85,17 +89,17 @@
|
|||||||
# },
|
# },
|
||||||
# }
|
# }
|
||||||
|
|
||||||
# 12. Copy a folder
|
# 11. Copy a folder
|
||||||
#curl -v -H "Content-Type: application/xml" -X POST --data "@file_or_folder_copy_move.xml" -H "X-Redmine-API-Key: ${USERS_API_KEY}" http://localhost:3000/dmsf/folders/53075/copy/copy.xml
|
#curl -v -H "Content-Type: application/xml" -X POST --data "@file_or_folder_copy_move.xml" -H "X-Redmine-API-Key: ${USERS_API_KEY}" http://localhost:3000/dmsf/folders/53075/copy/copy.xml
|
||||||
|
|
||||||
# 13. Move a folder
|
# 12. Move a folder
|
||||||
#curl -v -H "Content-Type: application/xml" -X POST --data "@file_or_folder_copy_move.xml" -H "X-Redmine-API-Key: ${USERS_API_KEY}" http://localhost:3000/dmsf/folders/53075/copy/move.xml
|
#curl -v -H "Content-Type: application/xml" -X POST --data "@file_or_folder_copy_move.xml" -H "X-Redmine-API-Key: ${USERS_API_KEY}" http://localhost:3000/dmsf/folders/53075/copy/move.xml
|
||||||
|
|
||||||
# 14. Delete a folder
|
# 13. Delete a folder
|
||||||
# a) Move to trash only
|
# a) Move to trash only
|
||||||
# curl -v -H "Content-Type: application/xml" -X DELETE -u ${USER_LOGIN}:${USER_PASSWORD} http://localhost:3000/projects/2387/dmsf/delete.xml?folder_id=#{folder_id}
|
# curl -v -H "Content-Type: application/xml" -X DELETE -u ${USER_LOGIN}:${USER_PASSWORD} http://localhost:3000/projects/2387/dmsf/delete.xml?folder_id=#{folder_id}
|
||||||
# b) Delete permanently
|
# b) Delete permanently
|
||||||
# curl -v -H "Content-Type: application/xml" -X DELETE -u ${USER_LOGIN}:${USER_PASSWORD} "http://localhost:3000/projects/2387/dmsf/delete.xml?folder_id=#{folder_id}&commit=yes"
|
# curl -v -H "Content-Type: application/xml" -X DELETE -u ${USER_LOGIN}:${USER_PASSWORD} "http://localhost:3000/projects/2387/dmsf/delete.xml?folder_id=#{folder_id}&commit=yes"
|
||||||
|
|
||||||
# 15. Create a symbolic link
|
# 14. Create a symbolic link
|
||||||
# curl -v -H "Content-Type: application/xml" -X POST --data "@link.xml" -H "X-Redmine-API-Key: ${USERS_API_KEY}" http://localhost:3000/dmsf_links.xml
|
# curl -v -H "Content-Type: application/xml" -X POST --data "@link.xml" -H "X-Redmine-API-Key: ${USERS_API_KEY}" http://localhost:3000/dmsf_links.xml
|
||||||
@ -145,4 +145,24 @@ class DmsfFileApiTest < RedmineDmsf::Test::IntegrationTest
|
|||||||
end
|
end
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_download_entries
|
||||||
|
# curl -v -H "Content-Type: application/xml" -X POST --data "" -H "X-Redmine-API-Key: ${USER_API_KEY}" \
|
||||||
|
# "http://localhost:3000/projects/3342/dmsf/entries.xml?ids[]=file-254566"
|
||||||
|
post "/projects/#{@project1.id}/dmsf/entries.xml?ids[]=file-#{@file1.id}&key=#{@token.value}",
|
||||||
|
params: '',
|
||||||
|
headers: { 'CONTENT_TYPE' => 'application/octet-stream' }
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_delete_entries
|
||||||
|
# curl -v -H "Content-Type: application/xml" -X POST --data "" -H "X-Redmine-API-Key: ${USER_API_KEY}" \
|
||||||
|
# "http://localhost:3000/projects/3342/dmsf/entries.xml?ids[]=file-254566&delete_entries=true"
|
||||||
|
assert_difference('@project1.dmsf_files.visible.count', -1) do
|
||||||
|
post "/projects/#{@project1.id}/dmsf/entries.xml?ids[]=file-#{@file1.id}&delete_entries=true&key=#{@token.value}",
|
||||||
|
params: '',
|
||||||
|
headers: { 'CONTENT_TYPE' => 'application/xml' }
|
||||||
|
end
|
||||||
|
assert_response :redirect
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user