You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original /restrict API only allowed for a boolean to update the restricted attribute of a file.
4
+
The extended API still allows for the single boolean for backward compatibility.
5
+
This change also allows for a JSON object to be passed which allows for the required `restrict` flag as well as optional attributes: `enableAccessRequest` and `termsOfAccess`.
6
+
If `enableAccessRequest` is false then the `termsOfAccess` text must also be included.
7
+
8
+
See [the guides](https://dataverse-guide--11349.org.readthedocs.build/en/11349/api/native-api.html#restrict-files), #11299, and #11349.
Copy file name to clipboardexpand all lines: doc/sphinx-guides/source/api/native-api.rst
+29
Original file line number
Diff line number
Diff line change
@@ -4028,6 +4028,8 @@ Restrict Files
4028
4028
~~~~~~~~~~~~~~
4029
4029
4030
4030
Restrict or unrestrict an existing file where ``id`` is the database id of the file or ``pid`` is the persistent id (DOI or Handle) of the file to restrict. Note that some Dataverse installations do not allow the ability to restrict files (see :ref:`:PublicInstall`).
4031
+
Restricting or Unrestricting a file, not in a draft version of the Dataset, will result in a new Draft version being created.
4032
+
Optionally the API can receive a JSON string with additional parameters related to the ability to request access to the file and the terms of that access.
4031
4033
4032
4034
A curl example using an ``id``
4033
4035
@@ -4061,6 +4063,33 @@ The fully expanded example above (without environment variables) looks like this
4061
4063
4062
4064
curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -X PUT -d true"https://demo.dataverse.org/api/files/:persistentId/restrict?persistentId=doi:10.5072/FK2/AAA000"
curl -H "X-Dataverse-key:$API_TOKEN" -X PUT "$SERVER_URL/api/files/$ID/restrict" \
4075
+
-H "Content-Type: application/json" \
4076
+
-d '{"restrict": true, "enableAccessRequest":false, "termsOfAccess": "Reason for the restricted access"}'
4077
+
4078
+
Note the behavior of the optional parameters:
4079
+
4080
+
- If restrict is falsethen enableAccessRequest and termsOfAccess are ignored
4081
+
- If restrict is true and enableAccessRequest is falsethen termsOfAccess is required. A status of CONFLICT (409) will be returned if the termsOfAccess is missing
4082
+
4083
+
The enableAccessRequest and termsOfAccess are applied to the Draft version of the Dataset and affect all of the restricted files in said Draft version.
4084
+
4085
+
The fully expanded example above (without environment variables) looks like this:
4086
+
4087
+
.. code-block:: bash
4088
+
4089
+
curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -X PUT "https://demo.dataverse.org/api/files/:persistentId/restrict?persistentId=doi:10.5072/FK2/AAA000" \
4090
+
-H "Content-Type: application/json" \
4091
+
-d '{"restrict": true, "enableAccessRequest":false, "termsOfAccess": "Reason for the restricted access"}'
.body("data.message", equalTo("File dataverseproject.png restricted. Access Request is disabled. Terms of Access for restricted files: Testing terms of access"))
0 commit comments