-
-
Notifications
You must be signed in to change notification settings - Fork 92
Add endpoint for managing recycle bin #1920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rohnsha0
wants to merge
14
commits into
main
Choose a base branch
from
rohnsha0-feat-recyclebin-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
cdb3dda
feat(recyclebin): add REST API services for recyclebin management
rohnsha0 659bdc3
feat(recyclebin): refactor and enhance REST API for recyclebin manage…
rohnsha0 8055417
test(recyclebin): add tests for recycle bin REST API functionality
rohnsha0 76293ec
lint
rohnsha0 4f1ad73
changelog
rohnsha0 97aa41f
Apply suggestions from code review
rohnsha0 04016ce
add docs
rohnsha0 860422c
Update interface location
davisagli 9bd36fe
Merge branch 'main' into rohnsha0-feat-recyclebin-api
rohnsha0 a82bfcf
feat(recyclebin): enhance recycle bin service with filtering, sorting…
rohnsha0 a590b13
feat(recyclebin): change purge endpoint to DELETE and update related …
rohnsha0 1487920
feat(recyclebin): update restore endpoint to use item_id in URL and a…
rohnsha0 164245b
feat(recyclebin): implement individual item retrieval and enhance err…
rohnsha0 0561f49
feat(recyclebin): enhance documentation and implement detailed item r…
rohnsha0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,7 @@ portrait | |
| principals | ||
| querystring | ||
| querystringsearch | ||
| recycle-bin | ||
| registry | ||
| relations | ||
| roles | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,131 @@ | ||||||
| --- | ||||||
| myst: | ||||||
| html_meta: | ||||||
| "description": "The Recycle Bin REST API provides endpoints to interact with the Plone Recycle Bin functionality." | ||||||
| "property=og:description": "The Recycle Bin REST API provides endpoints to interact with the Plone Recycle Bin functionality." | ||||||
| "property=og:title": "Recycle Bin" | ||||||
| "keywords": "Plone, plone.restapi, REST, API, Recycle Bin" | ||||||
| --- | ||||||
|
|
||||||
| # Recycle Bin | ||||||
|
|
||||||
| The Recycle Bin REST API provides endpoints to interact with the Plone Recycle Bin functionality. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| Reading or writing recycle bin data requires the `cmf.ManagePortal` permission. | ||||||
|
|
||||||
| ## List recycle bin contents | ||||||
|
|
||||||
| A list of all items in the recycle bin can be retrieved by sending a `GET` request to the `@recyclebin` endpoint: | ||||||
|
|
||||||
| ```{eval-rst} | ||||||
| .. http:example:: curl httpie python-requests | ||||||
| :request: ../../../src/plone/restapi/tests/http-examples/recyclebin_get.req | ||||||
| ``` | ||||||
|
|
||||||
| ```{literalinclude} ../../../src/plone/restapi/tests/http-examples/recyclebin_get.resp | ||||||
| :language: http | ||||||
| ``` | ||||||
|
|
||||||
| ### Filtering and Sorting Parameters | ||||||
|
|
||||||
| The listing supports various query parameters for filtering and sorting: | ||||||
|
|
||||||
| - `search_query`: Search in title and path (case-insensitive) | ||||||
| - `filter_type`: Filter by content type (e.g., "Document", "Folder") | ||||||
| - `date_from`: Filter by deletion date from (YYYY-MM-DD format) | ||||||
| - `date_to`: Filter by deletion date to (YYYY-MM-DD format) | ||||||
| - `filter_deleted_by`: Filter by user who deleted the item | ||||||
| - `filter_has_subitems`: Filter items with/without children (`with_subitems`, `without_subitems`) | ||||||
| - `filter_language`: Filter by language code | ||||||
| - `filter_workflow_state`: Filter by workflow state | ||||||
| - `sort_by`: Sorting options: | ||||||
| - `date_desc` (default) - Most recent first | ||||||
| - `date_asc` - Oldest first | ||||||
| - `title_asc` / `title_desc` - Alphabetical by title | ||||||
| - `type_asc` / `type_desc` - By content type | ||||||
| - `path_asc` / `path_desc` - By path | ||||||
| - `size_asc` / `size_desc` - By size | ||||||
| - `workflow_asc` / `workflow_desc` - By workflow state | ||||||
|
|
||||||
| ### Batching | ||||||
|
|
||||||
| The API supports standard Plone REST API batching parameters: | ||||||
|
|
||||||
| - `b_start`: Starting position for batch | ||||||
| - `b_size`: Number of items per batch | ||||||
|
|
||||||
| #### Example with filtering and sorting | ||||||
|
|
||||||
| ```{eval-rst} | ||||||
| .. http:example:: curl httpie python-requests | ||||||
| :request: ../../../src/plone/restapi/tests/http-examples/recyclebin_get_filtered.req | ||||||
| ``` | ||||||
|
|
||||||
| ```{literalinclude} ../../../src/plone/restapi/tests/http-examples/recyclebin_get_filtered.resp | ||||||
| :language: http | ||||||
| ``` | ||||||
|
|
||||||
| ## Get individual item from recycle bin | ||||||
|
|
||||||
| To retrieve detailed information about a specific item in the recycle bin, send a GET request to `@recyclebin/{item_id}`: | ||||||
|
|
||||||
| ```{eval-rst} | ||||||
| .. http:example:: curl httpie python-requests | ||||||
| :request: ../../../src/plone/restapi/tests/http-examples/recyclebin_get_item.req | ||||||
| ``` | ||||||
|
|
||||||
| ```{literalinclude} ../../../src/plone/restapi/tests/http-examples/recyclebin_get_item.resp | ||||||
| :language: http | ||||||
| ``` | ||||||
|
|
||||||
| ## Restore an item from the recycle bin | ||||||
|
|
||||||
| An item can be restored from the recycle bin by issuing a `POST` to the given URL: | ||||||
|
|
||||||
| ```{eval-rst} | ||||||
| .. http:example:: curl httpie python-requests | ||||||
| :request: ../../../src/plone/restapi/tests/http-examples/recyclebin_restore.req | ||||||
| ``` | ||||||
|
|
||||||
| ```{literalinclude} ../../../src/plone/restapi/tests/http-examples/recyclebin_restore.resp | ||||||
| :language: http | ||||||
| ``` | ||||||
|
|
||||||
| ### Restore to specific target location | ||||||
|
|
||||||
| You can specify a target path to restore the item to a different location than its original: | ||||||
|
|
||||||
| ```{eval-rst} | ||||||
| .. http:example:: curl httpie python-requests | ||||||
| :request: ../../../src/plone/restapi/tests/http-examples/recyclebin_restore_target.req | ||||||
| ``` | ||||||
|
|
||||||
| ```{literalinclude} ../../../src/plone/restapi/tests/http-examples/recyclebin_restore_target.resp | ||||||
| :language: http | ||||||
| ``` | ||||||
|
|
||||||
| ## Purge a specific item from the recycle bin | ||||||
|
|
||||||
| To permanently delete a specific item from the recycle bin, send a DELETE request to the `@recyclebin/{item_id}` endpoint: | ||||||
|
|
||||||
| ```{eval-rst} | ||||||
| .. http:example:: curl httpie python-requests | ||||||
| :request: ../../../src/plone/restapi/tests/http-examples/recyclebin_purge_item.req | ||||||
| ``` | ||||||
|
|
||||||
| ```{literalinclude} ../../../src/plone/restapi/tests/http-examples/recyclebin_purge_item.resp | ||||||
| :language: http | ||||||
| ``` | ||||||
|
|
||||||
| ## Empty the entire recycle bin | ||||||
|
|
||||||
| To permanently delete all items from the recycle bin, send a DELETE request to the `@recyclebin` endpoint: | ||||||
|
|
||||||
| ```{eval-rst} | ||||||
| .. http:example:: curl httpie python-requests | ||||||
| :request: ../../../src/plone/restapi/tests/http-examples/recyclebin_purge_all.req | ||||||
| ``` | ||||||
|
|
||||||
| ```{literalinclude} ../../../src/plone/restapi/tests/http-examples/recyclebin_purge_all.resp | ||||||
| :language: http | ||||||
| ``` | ||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add endpoint for managing recycle bin. @rohnsha0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # Empty init file to make the directory a Python package |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| <configure | ||
| xmlns="http://namespaces.zope.org/zope" | ||
| xmlns:plone="http://namespaces.plone.org/plone" | ||
| xmlns:zcml="http://namespaces.zope.org/zcml" | ||
| > | ||
|
|
||
| <include package="plone.restapi" /> | ||
|
|
||
| <plone:service | ||
| method="GET" | ||
| factory=".get.RecycleBinGet" | ||
| for="Products.CMFPlone.interfaces.IPloneSiteRoot" | ||
| permission="cmf.ManagePortal" | ||
| name="@recyclebin" | ||
| /> | ||
|
|
||
| <plone:service | ||
| method="GET" | ||
| factory=".get.RecycleBinGet" | ||
| for="Products.CMFCore.interfaces.IFolderish" | ||
| permission="cmf.ManagePortal" | ||
| name="@recyclebin" | ||
| /> | ||
|
|
||
| <plone:service | ||
| method="POST" | ||
| factory=".restore.RecycleBinRestore" | ||
| for="Products.CMFPlone.interfaces.IPloneSiteRoot" | ||
| permission="cmf.ManagePortal" | ||
| name="@recyclebin" | ||
| /> | ||
|
|
||
| <plone:service | ||
| method="DELETE" | ||
| factory=".purge.RecycleBinPurge" | ||
| for="Products.CMFPlone.interfaces.IPloneSiteRoot" | ||
| permission="cmf.ManagePortal" | ||
| name="@recyclebin" | ||
| /> | ||
|
|
||
| </configure> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above this page title, insert required html meta stuff. See other files in this directory for examples.