Skip to content

Commit

Permalink
Add @addons endpoint (#556)
Browse files Browse the repository at this point in the history
* Add beginnings of @addons endpoint

* Add @addon get response

* Add header

* Add @addons list response

* Add install, upgrade, uninstall on addons

* Add addons to toctree

* Don’t include paths.

* Add @id element to addons with url of its record

* Fix false, null.

* Status 200 doesn’t return content.

* 204 instead of 200

* Fix false/null

* Add get for @addons

* Add upgrade/install/uninstall methods to @addons

* Reorganize

* Move request/response examples

* Update example locations

* No need to batch the results

* Remove reinstall_products

* Handle product upgrade

* Remove unused method

* Add changelog entry.

* Move addon-lookup code into addons.py

* Flesh out tests some more

* Fix test values

* Check for prefer header, return all addons if set.

* Working install/uninstall test

* Remove unused imports

* Handle not-found addon

* Clean up Flake8 errors

* Sort imports

* Remove unused plone import from addons.py.

* Remove changelog merge message

* py3 fix.

* Flake 8

* Black

* Flake 8

* Fix tests

* Add upgrade tests

* Add upgrade tests

* Disable for Plone 4.3

Co-authored-by: Timo Stollenwerk <[email protected]>
Co-authored-by: Rodrigo Ferreira de Souza <[email protected]>
Co-authored-by: Victor Fernandez de Alba <[email protected]>
  • Loading branch information
4 people authored May 6, 2020
1 parent db18b17 commit 0e27a03
Show file tree
Hide file tree
Showing 21 changed files with 1,018 additions and 0 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
- Luca Bellenghi
- Giacomo Monari
- Alin Voinea
- Rodrigo Ferreira de Souza
83 changes: 83 additions & 0 deletions docs/source/addons.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
Add-ons
========

Addon product records can be addressed through the ``@addons`` endpoint on the
Plone site. In order to address a specific record, the profile id has to be
passed as a path segment (e.g. `/plone/@addons/plone.session`).

Reading or writing addons metadata require the ``cmf.ManagePortal``
permission.

Reading add-ons records
-----------------------

Reading a single record:

.. http:example:: curl httpie python-requests
:request: ../../src/plone/restapi/tests/http-examples/addons_get.req

Example Response:

.. literalinclude:: ../../src/plone/restapi/tests/http-examples/addons_get.resp
:language: http


Listing add-ons records
-----------------------

A list of all add-ons in the portal can be retrieved by
sending a GET request to the @addons endpoint:

.. http:example:: curl httpie python-requests
:request: ../../src/plone/restapi/tests/http-examples/addons_get_list.req

Response:

.. literalinclude:: ../../src/plone/restapi/tests/http-examples/addons_get_list.resp
:language: http

The following fields are returned:

- @id: hypermedia link to the control panel
- id: the name of the add-on package
- title: the friendly name of the add-on package
- description: description of the add-on
- version: the current version of the add-on
- is_installed: is the add-on installed?
- has_uninstall_profile: does the add-on have an uninstall profile


Installing an addon
-------------------

An individual addon can be installed by issuing a ``POST`` to the given URL:

.. http:example:: curl httpie python-requests
:request: ../../src/plone/restapi/tests/http-examples/addons_install.req

.. literalinclude:: ../../src/plone/restapi/tests/http-examples/addons_install.resp
:language: http


Uninstalling an addon
-------------------

An individual addon can be uninstalled by issuing a ``POST`` to the given URL:

.. http:example:: curl httpie python-requests
:request: ../../src/plone/restapi/tests/http-examples/addons_uninstall.req

.. literalinclude:: ../../src/plone/restapi/tests/http-examples/addons_uninstall.resp
:language: http


Upgrading an addon
-------------------

An individual addon can be upgraded by issuing a ``POST`` to the given URL:

.. http:example:: curl httpie python-requests
:request: ../../src/plone/restapi/tests/http-examples/addons_upgrade.req

.. literalinclude:: ../../src/plone/restapi/tests/http-examples/addons_upgrade.resp
:language: http
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Contents
blocks
history
batching
addons
comments
copymove
expansion
Expand Down
1 change: 1 addition & 0 deletions news/733.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add endpoints for managing addons. [esteele]
Empty file.
Loading

0 comments on commit 0e27a03

Please sign in to comment.