Skip to content

Commit

Permalink
Merge pull request #9646 from lmaylein/develop
Browse files Browse the repository at this point in the history
Unify and de-duplicate role creation information.
  • Loading branch information
kcondon authored Jul 24, 2023
2 parents 72f2481 + f1e7443 commit 77b7769
Showing 1 changed file with 25 additions and 28 deletions.
53 changes: 25 additions & 28 deletions doc/sphinx-guides/source/api/native-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ The fully expanded example above (without environment variables) looks like this
curl -H X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -X POST -H "Content-type:application/json" https://demo.dataverse.org/api/dataverses/root/metadatablockfacets/isRoot -d 'true'
.. _create-role-in-collection:

Create a New Role in a Dataverse Collection
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand All @@ -317,16 +319,7 @@ The fully expanded example above (without environment variables) looks like this
curl -H X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -X POST -H "Content-type:application/json" https://demo.dataverse.org/api/dataverses/root/roles --upload-file roles.json
Where ``roles.json`` looks like this::

{
"alias": "sys1",
"name": “Restricted System Role”,
"description": “A person who may only add datasets.”,
"permissions": [
"AddDataset"
]
}
For ``roles.json`` see :ref:`json-representation-of-a-role`

.. note:: Only a Dataverse installation account with superuser permissions is allowed to create roles in a Dataverse Collection.

Expand Down Expand Up @@ -3094,26 +3087,14 @@ Optionally, you may use a third query parameter "sendEmailNotification=false" to
Roles
-----
Create a New Role in a Dataverse Collection
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Creates a new role under Dataverse collection ``id``. Needs a json file with the role description:
.. code-block:: bash
export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
export SERVER_URL=https://demo.dataverse.org
export ID=root
curl -H X-Dataverse-key:$API_TOKEN -X POST -H "Content-type:application/json" $SERVER_URL/api/dataverses/$ID/roles --upload-file roles.json
A role is a set of permissions.
The fully expanded example above (without environment variables) looks like this:
.. code-block:: bash
.. _json-representation-of-a-role:
curl -H X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -X POST -H "Content-type:application/json" https://demo.dataverse.org/api/dataverses/root/roles --upload-file roles.json
JSON Representation of a Role
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Where ``roles.json`` looks like this::
The JSON representation of a role (``roles.json``) looks like this::
{
"alias": "sys1",
Expand All @@ -3124,8 +3105,12 @@ Where ``roles.json`` looks like this::
]
}
.. note:: Only a Dataverse installation account with superuser permissions is allowed to create roles in a Dataverse Collection.
.. note:: alias is constrained to a length of 16 characters
Create Role
~~~~~~~~~~~
Roles can be created globally (:ref:`create-global-role`) or for individual Dataverse collections (:ref:`create-role-in-collection`).
Show Role
~~~~~~~~~
Expand Down Expand Up @@ -3986,12 +3971,24 @@ List all global roles in the system. ::

GET http://$SERVER/api/admin/roles

.. _create-global-role:

Create Global Role
~~~~~~~~~~~~~~~~~~

Creates a global role in the Dataverse installation. The data POSTed are assumed to be a role JSON. ::

POST http://$SERVER/api/admin/roles

.. code-block:: bash
export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
export SERVER_URL=https://demo.dataverse.org
export ID=root
curl -H X-Dataverse-key:$API_TOKEN -X POST $SERVER_URL/api/admin/roles --upload-file roles.json
``roles.json`` see :ref:`json-representation-of-a-role`

Delete Global Role
~~~~~~~~~~~~~~~~~~
Expand Down

0 comments on commit 77b7769

Please sign in to comment.