From cdcaf19b03bb88e9f05c2dbe3d8322c60bed5b6c Mon Sep 17 00:00:00 2001 From: Peter Kiraly Date: Sat, 1 Feb 2020 16:35:48 +0100 Subject: [PATCH 01/13] #6083 update examples in Dataset part of Native API: 'Import a Dataset into a Dataverse' section. --- doc/sphinx-guides/source/api/native-api.rst | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/sphinx-guides/source/api/native-api.rst b/doc/sphinx-guides/source/api/native-api.rst index 163f35beb55..db27d3714b0 100644 --- a/doc/sphinx-guides/source/api/native-api.rst +++ b/doc/sphinx-guides/source/api/native-api.rst @@ -486,11 +486,22 @@ Import a Dataset into a Dataverse .. note:: This action requires a Dataverse account with super-user permissions. -To import a dataset with an existing persistent identifier (PID), the dataset's metadata should be prepared in Dataverse's native JSON format. The PID is provided as a parameter at the URL. The following line imports a dataset with the PID ``PERSISTENT_IDENTIFIER`` to Dataverse, and then releases it:: +To import a dataset with an existing persistent identifier (PID), the dataset's metadata should be prepared in Dataverse's native JSON format. The PID is provided as a parameter at the URL. The following line imports a dataset with the PID ``DATASET_PID`` to Dataverse, and then releases it: .. code-block:: bash - curl -H X-Dataverse-key:$API_TOKEN -X POST $SERVER_URL/api/dataverses/$DV_ALIAS/datasets/:import?pid=$PERSISTENT_IDENTIFIER&release=yes --upload-file dataset.json + export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + export SERVER_URL=https://demo.dataverse.org + export DATAVERSE_ID=root + export DATASET_PID=doi:ZZ7/MOSEISLEYDB94 + + curl -H X-Dataverse-key:$API_TOKEN -X POST $SERVER_URL/api/dataverses/$DATAVERSE_ID/datasets/:import?pid=$DATASET_PID&release=yes --upload-file dataset.json + +The fully expanded example above (without environment variables) looks like this: + +.. code-block:: bash + + curl -H X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -X POST https://demo.dataverse.org/api/dataverses/root/datasets/:import?pid=doi:ZZ7/MOSEISLEYDB94&release=yes --upload-file dataset.json The ``pid`` parameter holds a persistent identifier (such as a DOI or Handle). The import will fail if no PID is provided, or if the provided PID fails validation. From e9c1503e1d20e2a0844367bc69005c33a0a0c270 Mon Sep 17 00:00:00 2001 From: Peter Kiraly Date: Sat, 1 Feb 2020 17:17:58 +0100 Subject: [PATCH 02/13] #6083 update examples in Dataset part of Native API: 'Import a Dataset into a Dataverse with a DDI file' section. --- doc/sphinx-guides/source/api/native-api.rst | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/doc/sphinx-guides/source/api/native-api.rst b/doc/sphinx-guides/source/api/native-api.rst index db27d3714b0..fa9b103d27a 100644 --- a/doc/sphinx-guides/source/api/native-api.rst +++ b/doc/sphinx-guides/source/api/native-api.rst @@ -486,16 +486,16 @@ Import a Dataset into a Dataverse .. note:: This action requires a Dataverse account with super-user permissions. -To import a dataset with an existing persistent identifier (PID), the dataset's metadata should be prepared in Dataverse's native JSON format. The PID is provided as a parameter at the URL. The following line imports a dataset with the PID ``DATASET_PID`` to Dataverse, and then releases it: +To import a dataset with an existing persistent identifier (PID), the dataset's metadata should be prepared in Dataverse's native JSON format. The PID is provided as a parameter at the URL. The following line imports a dataset with the PID ``PERSISTENT_IDENTIFIER`` to Dataverse, and then releases it: .. code-block:: bash export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx export SERVER_URL=https://demo.dataverse.org export DATAVERSE_ID=root - export DATASET_PID=doi:ZZ7/MOSEISLEYDB94 + export PERSISTENT_IDENTIFIER=doi:ZZ7/MOSEISLEYDB94 - curl -H X-Dataverse-key:$API_TOKEN -X POST $SERVER_URL/api/dataverses/$DATAVERSE_ID/datasets/:import?pid=$DATASET_PID&release=yes --upload-file dataset.json + curl -H X-Dataverse-key:$API_TOKEN -X POST $SERVER_URL/api/dataverses/$DATAVERSE_ID/datasets/:import?pid=$PERSISTENT_IDENTIFIER&release=yes --upload-file dataset.json The fully expanded example above (without environment variables) looks like this: @@ -531,7 +531,18 @@ To import a dataset with an existing persistent identifier (PID), you have to pr .. code-block:: bash - curl -H X-Dataverse-key:$API_TOKEN -X POST $SERVER_URL/api/dataverses/$DV_ALIAS/datasets/:importddi?pid=$PERSISTENT_IDENTIFIER&release=yes --upload-file ddi_dataset.xml + export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + export SERVER_URL=https://demo.dataverse.org + export DATAVERSE_ID=root + export PERSISTENT_IDENTIFIER=doi:ZZ7/MOSEISLEYDB94 + + curl -H X-Dataverse-key:$API_TOKEN -X POST $SERVER_URL/api/dataverses/$DATAVERSE_ID/datasets/:importddi?pid=$PERSISTENT_IDENTIFIER&release=yes --upload-file ddi_dataset.xml + +The fully expanded example above (without environment variables) looks like this: + +.. code-block:: bash + + curl -H X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -X POST https://demo.dataverse.org/api/dataverses/root/datasets/:importddi?pid=doi:ZZ7/MOSEISLEYDB94&release=yes --upload-file ddi_dataset.xml The optional ``pid`` parameter holds a persistent identifier (such as a DOI or Handle). The import will fail if the provided PID fails validation. From 40557ba6967d518b4263a43c59dd74ad73661558 Mon Sep 17 00:00:00 2001 From: Peter Kiraly Date: Sat, 1 Feb 2020 17:20:19 +0100 Subject: [PATCH 03/13] #6083 update examples in Dataset part of Native API: 'Publish a Dataverse' section. --- doc/sphinx-guides/source/api/native-api.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/sphinx-guides/source/api/native-api.rst b/doc/sphinx-guides/source/api/native-api.rst index fa9b103d27a..6aaf594137a 100644 --- a/doc/sphinx-guides/source/api/native-api.rst +++ b/doc/sphinx-guides/source/api/native-api.rst @@ -567,10 +567,10 @@ In order to publish a dataverse, you must know either its "alias" (which the GUI .. code-block:: bash export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - export ALIAS=root export SERVER_URL=https://demo.dataverse.org + export ID=root - curl -H X-Dataverse-key:$API_TOKEN -X POST $SERVER_URL/api/dataverses/$ALIAS/actions/:publish + curl -H X-Dataverse-key:$API_TOKEN -X POST $SERVER_URL/api/dataverses/$ID/actions/:publish The fully expanded example above (without environment variables) looks like this: From 91a97bb6b5a59636c8aed7d1d418fa29589191e0 Mon Sep 17 00:00:00 2001 From: Peter Kiraly Date: Sat, 1 Feb 2020 18:15:40 +0100 Subject: [PATCH 04/13] #6083 update examples in Dataset part of Native API: 'Get JSON Representation of a Dataset' section. --- doc/sphinx-guides/source/api/native-api.rst | 72 ++++++++++++++------- 1 file changed, 49 insertions(+), 23 deletions(-) diff --git a/doc/sphinx-guides/source/api/native-api.rst b/doc/sphinx-guides/source/api/native-api.rst index 6aaf594137a..252ffef2ae7 100644 --- a/doc/sphinx-guides/source/api/native-api.rst +++ b/doc/sphinx-guides/source/api/native-api.rst @@ -151,7 +151,7 @@ The fully expanded example above (without environment variables) looks like this Report the data (file) size of a Dataverse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Shows the combined size in bytes of all the files uploaded into the dataverse ``id``. :: +Shows the combined size in bytes of all the files uploaded into the dataverse ``id``: .. code-block:: bash @@ -173,7 +173,7 @@ By default, only the archival files are counted - i.e., the files uploaded by us List Roles Defined in a Dataverse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -All the roles defined directly in the dataverse identified by ``id``:: +All the roles defined directly in the dataverse identified by ``id``: .. code-block:: bash @@ -192,7 +192,7 @@ The fully expanded example above (without environment variables) looks like this List Facets Configured for a Dataverse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -|CORS| List all the facets for a given dataverse ``id``:: +|CORS| List all the facets for a given dataverse ``id``: .. code-block:: bash @@ -211,7 +211,7 @@ The fully expanded example above (without environment variables) looks like this Set Facets for a Dataverse ~~~~~~~~~~~~~~~~~~~~~~~~~~ -Assign search facets for a given dataverse identified by ``id``:: +Assign search facets for a given dataverse identified by ``id``: .. code-block:: bash @@ -232,7 +232,7 @@ Where ``facets.json`` contains a JSON encoded list of metadata keys (e.g. ``["au Create a New Role in a Dataverse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Creates a new role under dataverse ``id``. Needs a json file with the role description:: +Creates a new role under dataverse ``id``. Needs a json file with the role description: .. code-block:: bash @@ -264,7 +264,7 @@ Where ``roles.json`` looks like this:: List Role Assignments in a Dataverse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -List all the role assignments at the given dataverse:: +List all the role assignments at the given dataverse: .. code-block:: bash @@ -283,7 +283,7 @@ The fully expanded example above (without environment variables) looks like this Assign Default Role to User Creating a Dataset in a Dataverse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Assign a default role to a user creating a dataset in a dataverse ``id`` where ``roleAlias`` is the database alias of the role to be assigned:: +Assign a default role to a user creating a dataset in a dataverse ``id`` where ``roleAlias`` is the database alias of the role to be assigned: .. code-block:: bash @@ -307,7 +307,7 @@ Note: You may use "none" as the ``ROLE_ALIAS``. This will prevent a user who cre Assign a New Role on a Dataverse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Assigns a new role, based on the POSTed JSON. :: +Assigns a new role, based on the POSTed JSON: .. code-block:: bash @@ -335,7 +335,7 @@ POSTed JSON example (the content of ``role.json`` file):: Delete Role Assignment from a Dataverse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Delete the assignment whose id is ``$id``:: +Delete the assignment whose id is ``$id``: .. code-block:: bash @@ -403,7 +403,7 @@ The fully expanded example above (without environment variables) looks like this Determine if a Dataverse Inherits Its Metadata Blocks from Its Parent ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Get whether the dataverse is a metadata block root, or does it uses its parent blocks:: +Get whether the dataverse is a metadata block root, or does it uses its parent blocks: .. code-block:: bash @@ -423,7 +423,7 @@ Configure a Dataverse to Inherit Its Metadata Blocks from Its Parent ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Set whether the dataverse is a metadata block root, or does it uses its parent blocks. Possible -values are ``true`` and ``false`` (both are valid JSON expressions). :: +values are ``true`` and ``false`` (both are valid JSON expressions): .. code-block:: bash @@ -501,7 +501,7 @@ The fully expanded example above (without environment variables) looks like this .. code-block:: bash - curl -H X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -X POST https://demo.dataverse.org/api/dataverses/root/datasets/:import?pid=doi:ZZ7/MOSEISLEYDB94&release=yes --upload-file dataset.json + curl -H X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -X POST https://demo.dataverse.org/api/dataverses/root/datasets/:import?pid=doi:ZZ7/MOSEISLEYDB94&release=yes --upload-file dataset.json The ``pid`` parameter holds a persistent identifier (such as a DOI or Handle). The import will fail if no PID is provided, or if the provided PID fails validation. @@ -527,7 +527,7 @@ Import a Dataset into a Dataverse with a DDI file .. note:: This action requires a Dataverse account with super-user permissions. -To import a dataset with an existing persistent identifier (PID), you have to provide the PID as a parameter at the URL. The following line imports a dataset with the PID ``PERSISTENT_IDENTIFIER`` to Dataverse, and then releases it:: +To import a dataset with an existing persistent identifier (PID), you have to provide the PID as a parameter at the URL. The following line imports a dataset with the PID ``PERSISTENT_IDENTIFIER`` to Dataverse, and then releases it: .. code-block:: bash @@ -598,26 +598,52 @@ Get JSON Representation of a Dataset .. note:: Datasets can be accessed using persistent identifiers. This is done by passing the constant ``:persistentId`` where the numeric id of the dataset is expected, and then passing the actual persistent id as a query parameter with the name ``persistentId``. - Example: Getting the dataset whose DOI is *10.5072/FK2/J8SJZB* :: +Example: Getting the dataset whose DOI is *10.5072/FK2/J8SJZB*: - curl http://$SERVER/api/datasets/:persistentId/?persistentId=doi:10.5072/FK2/J8SJZB +.. code-block:: bash + + export SERVER_URL=https://demo.dataverse.org + export PERSISTENT_IDENTIFIER=doi:10.5072/FK2/J8SJZB + + curl $SERVER_URL/api/datasets/:persistentId/?persistentId=$PERSISTENT_IDENTIFIER + +The fully expanded example above (without environment variables) looks like this: + +.. code-block:: bash + + curl https://demo.dataverse.org/api/datasets/:persistentId/?persistentId=doi:10.5072/FK2/J8SJZB + +Getting its draft version: + +.. code-block:: bash - fully expanded:: + export SERVER_URL=https://demo.dataverse.org + export PERSISTENT_IDENTIFIER=doi:10.5072/FK2/J8SJZB + + curl http://$SERVER/api/datasets/:persistentId/versions/:draft?persistentId=$PERSISTENT_IDENTIFIER + +The fully expanded example above (without environment variables) looks like this: + +.. code-block:: bash - curl http://localhost:8080/api/datasets/:persistentId/?persistentId=doi:10.5072/FK2/J8SJZB + curl https://demo.dataverse.org/api/datasets/:persistentId/versions/:draft?persistentId=doi:10.5072/FK2/J8SJZB - Getting its draft version:: - curl http://$SERVER/api/datasets/:persistentId/versions/:draft?persistentId=doi:10.5072/FK2/J8SJZB +|CORS| Show the dataset whose id is passed: - fully expanded:: +.. code-block:: bash + + export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + export SERVER_URL=https://demo.dataverse.org + export PERSISTENT_IDENTIFIER=doi:10.5072/FK2/J8SJZB - curl http://localhost:8080/api/datasets/:persistentId/versions/:draft?persistentId=doi:10.5072/FK2/J8SJZB + curl -H X-Dataverse-key:$API_TOKEN $SERVER_URL/api/datasets/$ID +The fully expanded example above (without environment variables) looks like this: -|CORS| Show the dataset whose id is passed:: +.. code-block:: bash - GET http://$SERVER/api/datasets/$id?key=$apiKey + curl -H X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx https://demo.dataverse.org/api/datasets/doi:10.5072/FK2/J8SJZB List Versions of a Dataset ~~~~~~~~~~~~~~~~~~~~~~~~~~ From 65f6b3e3afd115d5c3682fb2b95501468a1316f8 Mon Sep 17 00:00:00 2001 From: Peter Kiraly Date: Sat, 1 Feb 2020 19:07:58 +0100 Subject: [PATCH 05/13] #6083 update examples in Dataset part of Native API: 'Get JSON Representation of a Dataset' section. --- doc/sphinx-guides/source/api/native-api.rst | 22 +++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/doc/sphinx-guides/source/api/native-api.rst b/doc/sphinx-guides/source/api/native-api.rst index 252ffef2ae7..84e67f6ccb4 100644 --- a/doc/sphinx-guides/source/api/native-api.rst +++ b/doc/sphinx-guides/source/api/native-api.rst @@ -633,24 +633,38 @@ The fully expanded example above (without environment variables) looks like this .. code-block:: bash - export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx export SERVER_URL=https://demo.dataverse.org - export PERSISTENT_IDENTIFIER=doi:10.5072/FK2/J8SJZB + export ID=408730 - curl -H X-Dataverse-key:$API_TOKEN $SERVER_URL/api/datasets/$ID + curl $SERVER_URL/api/datasets/$ID The fully expanded example above (without environment variables) looks like this: .. code-block:: bash - curl -H X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx https://demo.dataverse.org/api/datasets/doi:10.5072/FK2/J8SJZB + curl https://demo.dataverse.org/api/datasets/408730 + +The dataset id can be extracted from the response retrieved from the API which uses the persistent identifier (``/api/datasets/:persistentId/?persistentId=$PERSISTENT_IDENTIFIER``). List Versions of a Dataset ~~~~~~~~~~~~~~~~~~~~~~~~~~ |CORS| List versions of the dataset:: +.. code-block:: bash + + export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + export SERVER_URL=https://demo.dataverse.org + export PERSISTENT_IDENTIFIER=doi:ZZ7/MOSEISLEYDB94 + + curl -H X-Dataverse-key:$API_TOKEN $SERVER_URL/api/dataverses/$ID/versions + +The fully expanded example above (without environment variables) looks like this: + +.. code-block:: bash + GET http://$SERVER/api/datasets/$id/versions?key=$apiKey + curl -H X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx https://demo.dataverse.org/api/dataverses/root Get Version of a Dataset ~~~~~~~~~~~~~~~~~~~~~~~~ From a823bc4bc8bf5e4d470c208919174acad45cf6f0 Mon Sep 17 00:00:00 2001 From: Peter Kiraly Date: Sat, 1 Feb 2020 19:38:23 +0100 Subject: [PATCH 06/13] #6083 update examples in Dataset part of Native API: 'List Versions of a Dataset' section. --- doc/sphinx-guides/source/api/native-api.rst | 58 ++++++++++++++++++--- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/doc/sphinx-guides/source/api/native-api.rst b/doc/sphinx-guides/source/api/native-api.rst index 84e67f6ccb4..9079a74f93a 100644 --- a/doc/sphinx-guides/source/api/native-api.rst +++ b/doc/sphinx-guides/source/api/native-api.rst @@ -649,22 +649,68 @@ The dataset id can be extracted from the response retrieved from the API which u List Versions of a Dataset ~~~~~~~~~~~~~~~~~~~~~~~~~~ -|CORS| List versions of the dataset:: +|CORS| List versions of the dataset: .. code-block:: bash - export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx export SERVER_URL=https://demo.dataverse.org - export PERSISTENT_IDENTIFIER=doi:ZZ7/MOSEISLEYDB94 + export ID=24 - curl -H X-Dataverse-key:$API_TOKEN $SERVER_URL/api/dataverses/$ID/versions + curl $SERVER_URL/api/dataverses/$ID/versions The fully expanded example above (without environment variables) looks like this: .. code-block:: bash - GET http://$SERVER/api/datasets/$id/versions?key=$apiKey - curl -H X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx https://demo.dataverse.org/api/dataverses/root + curl https://demo.dataverse.org/api/datasets/24/versions + +It returns a list of versions with their metadata, and file list: + +.. code-block:: bash + + { + "status": "OK", + "data": [ + { + "id": 7, + "datasetId": 24, + "datasetPersistentId": "doi:10.5072/FK2/U6AEZM", + "storageIdentifier": "file://10.5072/FK2/U6AEZM", + "versionNumber": 2, + "versionMinorNumber": 0, + "versionState": "RELEASED", + "lastUpdateTime": "2015-04-20T09:58:35Z", + "releaseTime": "2015-04-20T09:58:35Z", + "createTime": "2015-04-20T09:57:32Z", + "license": "CC0", + "termsOfUse": "CC0 Waiver", + "termsOfAccess": "You need to request for access.", + "fileAccessRequest": true, + "metadataBlocks": {...}, + "files": [...] + }, + { + "id": 6, + "datasetId": 24, + "datasetPersistentId": "doi:10.5072/FK2/U6AEZM", + "storageIdentifier": "file://10.5072/FK2/U6AEZM", + "versionNumber": 1, + "versionMinorNumber": 0, + "versionState": "RELEASED", + "UNF": "UNF:6:y4dtFxWhBaPM9K/jlPPuqg==", + "lastUpdateTime": "2015-04-20T09:56:34Z", + "releaseTime": "2015-04-20T09:56:34Z", + "createTime": "2015-04-20T09:43:45Z", + "license": "CC0", + "termsOfUse": "CC0 Waiver", + "termsOfAccess": "You need to request for access.", + "fileAccessRequest": true, + "metadataBlocks": {...}, + "files": [...] + } + ] + } + Get Version of a Dataset ~~~~~~~~~~~~~~~~~~~~~~~~ From 3cd2f333844af418be36ba8700b29fd240774c17 Mon Sep 17 00:00:00 2001 From: Peter Kiraly Date: Sat, 1 Feb 2020 19:47:51 +0100 Subject: [PATCH 07/13] #6083 update examples in Dataset part of Native API: 'Get Version of a Dataset' section. --- doc/sphinx-guides/source/api/native-api.rst | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/doc/sphinx-guides/source/api/native-api.rst b/doc/sphinx-guides/source/api/native-api.rst index 9079a74f93a..e168b3ad007 100644 --- a/doc/sphinx-guides/source/api/native-api.rst +++ b/doc/sphinx-guides/source/api/native-api.rst @@ -715,9 +715,21 @@ It returns a list of versions with their metadata, and file list: Get Version of a Dataset ~~~~~~~~~~~~~~~~~~~~~~~~ -|CORS| Show a version of the dataset. The output includes any metadata blocks the dataset might have:: +|CORS| Show a version of the dataset. The output includes any metadata blocks the dataset might have: - GET http://$SERVER/api/datasets/$id/versions/$versionNumber?key=$apiKey +.. code-block:: bash + + export SERVER_URL=https://demo.dataverse.org + export ID=24 + export VERSION=1.0 + + curl $SERVER_URL/api/datasets/$ID/versions/$VERSION + +The fully expanded example above (without environment variables) looks like this: + +.. code-block:: bash + + curl https://demo.dataverse.org/api/datasets/24/versions/1.0 .. _export-dataset-metadata-api: From 212679247ab8dae022eb80f2d1a5d7f883f0e1eb Mon Sep 17 00:00:00 2001 From: Peter Kiraly Date: Sat, 1 Feb 2020 21:50:40 +0100 Subject: [PATCH 08/13] #6083 update examples in Dataset part of Native API: 'Export Metadata of a Dataset in Various Formats' section. --- doc/sphinx-guides/source/api/native-api.rst | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/doc/sphinx-guides/source/api/native-api.rst b/doc/sphinx-guides/source/api/native-api.rst index e168b3ad007..3441f98d813 100644 --- a/doc/sphinx-guides/source/api/native-api.rst +++ b/doc/sphinx-guides/source/api/native-api.rst @@ -738,7 +738,19 @@ Export Metadata of a Dataset in Various Formats |CORS| Export the metadata of the current published version of a dataset in various formats see Note below:: - GET http://$SERVER/api/datasets/export?exporter=ddi&persistentId=$persistentId +.. code-block:: bash + + export SERVER_URL=https://demo.dataverse.org + export PERSISTENT_IDENTIFIER=doi:10.5072/FK2/J8SJZB + export METADATA_FORMAT=ddi + + curl $SERVER_URL/api/datasets/export?exporter=$METADATA_FORMAT&persistentId=PERSISTENT_IDENTIFIER + +The fully expanded example above (without environment variables) looks like this: + +.. code-block:: bash + + curl https://demo.dataverse.org/api/datasets/export?exporter=ddi&persistentId=doi:10.5072/FK2/J8SJZB .. note:: Supported exporters (export formats) are ``ddi``, ``oai_ddi``, ``dcterms``, ``oai_dc``, ``schema.org`` , ``OAI_ORE`` , ``Datacite``, ``oai_datacite`` and ``dataverse_json``. Descriptive names can be found under :ref:`metadata-export-formats` in the User Guide. From c41cee7c351cf57eb528ad506a9638e8ad117d64 Mon Sep 17 00:00:00 2001 From: Peter Kiraly Date: Sat, 1 Feb 2020 21:56:14 +0100 Subject: [PATCH 09/13] #6083 update examples in Dataset part of Native API: 'Export Metadata of a Dataset in Various Formats' section. --- doc/sphinx-guides/source/api/native-api.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/sphinx-guides/source/api/native-api.rst b/doc/sphinx-guides/source/api/native-api.rst index 3441f98d813..e25e9c0642c 100644 --- a/doc/sphinx-guides/source/api/native-api.rst +++ b/doc/sphinx-guides/source/api/native-api.rst @@ -736,7 +736,7 @@ The fully expanded example above (without environment variables) looks like this Export Metadata of a Dataset in Various Formats ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -|CORS| Export the metadata of the current published version of a dataset in various formats see Note below:: +|CORS| Export the metadata of the current published version of a dataset in various formats see Note below: .. code-block:: bash From e56426d1096782835af4961ad70aabf53831583a Mon Sep 17 00:00:00 2001 From: Peter Kiraly Date: Mon, 3 Feb 2020 13:56:50 +0100 Subject: [PATCH 10/13] #6083 update examples in Dataset part of Native API: 'List Files in a Dataset' section. --- doc/sphinx-guides/source/api/native-api.rst | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/doc/sphinx-guides/source/api/native-api.rst b/doc/sphinx-guides/source/api/native-api.rst index e25e9c0642c..87644b49120 100644 --- a/doc/sphinx-guides/source/api/native-api.rst +++ b/doc/sphinx-guides/source/api/native-api.rst @@ -768,9 +768,21 @@ Both forms are valid according to Google's Structured Data Testing Tool at https List Files in a Dataset ~~~~~~~~~~~~~~~~~~~~~~~ -|CORS| Lists all the file metadata, for the given dataset and version:: +|CORS| Lists all the file metadata, for the given dataset and version: - GET http://$SERVER/api/datasets/$id/versions/$versionId/files?key=$apiKey +.. code-block:: bash + + export SERVER_URL=https://demo.dataverse.org + export ID=24 + export VERSION=1.0 + + curl $SERVER_URL/api/datasets/$ID/versions/$VERSION/files + +The fully expanded example above (without environment variables) looks like this: + +.. code-block:: bash + + curl https://demo.dataverse.org/api/datasets/24/versions/1.0/files List All Metadata Blocks for a Dataset ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 7b8c25cae2b8422aac2b68fdd6825002573e506b Mon Sep 17 00:00:00 2001 From: Peter Kiraly Date: Mon, 3 Feb 2020 13:59:17 +0100 Subject: [PATCH 11/13] #6083 update examples in Dataset part of Native API: 'List All Metadata Blocks for a Dataset' section. --- doc/sphinx-guides/source/api/native-api.rst | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/doc/sphinx-guides/source/api/native-api.rst b/doc/sphinx-guides/source/api/native-api.rst index 87644b49120..b74e89698f9 100644 --- a/doc/sphinx-guides/source/api/native-api.rst +++ b/doc/sphinx-guides/source/api/native-api.rst @@ -787,9 +787,21 @@ The fully expanded example above (without environment variables) looks like this List All Metadata Blocks for a Dataset ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -|CORS| Lists all the metadata blocks and their content, for the given dataset and version:: +|CORS| Lists all the metadata blocks and their content, for the given dataset and version: - GET http://$SERVER/api/datasets/$id/versions/$versionId/metadata?key=$apiKey +.. code-block:: bash + + export SERVER_URL=https://demo.dataverse.org + export ID=24 + export VERSION=1.0 + + curl $SERVER_URL/api/datasets/$ID/versions/$VERSION/metadata + +The fully expanded example above (without environment variables) looks like this: + +.. code-block:: bash + + curl https://demo.dataverse.org/api/datasets/24/versions/1.0/metadata List Single Metadata Block for a Dataset ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 1e5087e03a599335d693f03435b01bd8638335e2 Mon Sep 17 00:00:00 2001 From: Peter Kiraly Date: Mon, 3 Feb 2020 14:08:36 +0100 Subject: [PATCH 12/13] #6083 update examples in Dataset part of Native API: 'List Single Metadata Block for a Dataset' section. --- doc/sphinx-guides/source/api/native-api.rst | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/doc/sphinx-guides/source/api/native-api.rst b/doc/sphinx-guides/source/api/native-api.rst index b74e89698f9..35011387a72 100644 --- a/doc/sphinx-guides/source/api/native-api.rst +++ b/doc/sphinx-guides/source/api/native-api.rst @@ -806,9 +806,22 @@ The fully expanded example above (without environment variables) looks like this List Single Metadata Block for a Dataset ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -|CORS| Lists the metadata block block named `blockname`, for the given dataset and version:: +|CORS| Lists the metadata block named `METADATA_BLOCK`, for the given dataset and version: - GET http://$SERVER/api/datasets/$id/versions/$versionId/metadata/$blockname?key=$apiKey +.. code-block:: bash + + export SERVER_URL=https://demo.dataverse.org + export ID=24 + export VERSION=1.0 + export METADATA_BLOCK=citation + + curl $SERVER_URL/api/datasets/$ID/versions/$VERSION/metadata/$METADATA_BLOCK + +The fully expanded example above (without environment variables) looks like this: + +.. code-block:: bash + + curl https://demo.dataverse.org/api/datasets/24/versions/1.0/metadata/citation Update Metadata For a Dataset ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From bc6f37d73daf6ed5001083b16c9336ed42340486 Mon Sep 17 00:00:00 2001 From: Peter Kiraly Date: Mon, 3 Feb 2020 14:26:32 +0100 Subject: [PATCH 13/13] #6083 update examples in Dataset part of Native API: 'Update Metadata For a Dataset' section. --- doc/sphinx-guides/source/api/native-api.rst | 32 ++++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/doc/sphinx-guides/source/api/native-api.rst b/doc/sphinx-guides/source/api/native-api.rst index 35011387a72..7a7fa52d120 100644 --- a/doc/sphinx-guides/source/api/native-api.rst +++ b/doc/sphinx-guides/source/api/native-api.rst @@ -830,13 +830,37 @@ Updates the metadata for a dataset. If a draft of the dataset already exists, th You must download a JSON representation of the dataset, edit the JSON you download, and then send the updated JSON to the Dataverse server. -For example, after making your edits, your JSON file might look like :download:`dataset-update-metadata.json <../_static/api/dataset-update-metadata.json>` which you would send to Dataverse like this:: +For example, after making your edits, your JSON file might look like :download:`dataset-update-metadata.json <../_static/api/dataset-update-metadata.json>` which you would send to Dataverse like this: - curl -H "X-Dataverse-key: $API_TOKEN" -X PUT $SERVER_URL/api/datasets/:persistentId/versions/:draft?persistentId=$PID --upload-file dataset-update-metadata.json +.. code-block:: bash + + export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + export SERVER_URL=https://demo.dataverse.org + export PERSISTENT_IDENTIFIER=doi:10.5072/FK2/BCCP9Z + + curl -H "X-Dataverse-key: $API_TOKEN" -X PUT $SERVER_URL/api/datasets/:persistentId/versions/:draft?persistentId=$PERSISTENT_IDENTIFIER --upload-file dataset-update-metadata.json + +The fully expanded example above (without environment variables) looks like this: + +.. code-block:: bash + + curl -H "X-Dataverse-key: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -X PUT https://demo.dataverse.org/api/datasets/:persistentId/versions/:draft?persistentId=doi:10.5072/FK2/BCCP9Z --upload-file dataset-update-metadata.json -Note that in the example JSON file above, there is a single JSON object with ``metadataBlocks`` as a key. When you download a representation of your dataset in JSON format, the ``metadataBlocks`` object you need is nested inside another object called ``json``. To extract just the ``metadataBlocks`` key when downloading a JSON representation, you can use a tool such as ``jq`` like this:: +Note that in the example JSON file above, there is a single JSON object with ``metadataBlocks`` as a key. When you download a representation of your dataset in JSON format, the ``metadataBlocks`` object you need is nested inside another object called ``json``. To extract just the ``metadataBlocks`` key when downloading a JSON representation, you can use a tool such as ``jq`` like this: + +.. code-block:: bash + + export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + export SERVER_URL=https://demo.dataverse.org + export PERSISTENT_IDENTIFIER=doi:10.5072/FK2/BCCP9Z + + curl -H "X-Dataverse-key: $API_TOKEN" $SERVER_URL/api/datasets/:persistentId/versions/:latest?persistentId=$PERSISTENT_IDENTIFIER | jq '.data | {metadataBlocks: .metadataBlocks}' > dataset-update-metadata.json + +The fully expanded example above (without environment variables) looks like this: + +.. code-block:: bash - curl -H "X-Dataverse-key: $API_TOKEN" $SERVER_URL/api/datasets/:persistentId/versions/:latest?persistentId=$PID | jq '.data | {metadataBlocks: .metadataBlocks}' > dataset-update-metadata.json + curl -H "X-Dataverse-key: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" https://demo.dataverse.org/api/datasets/:persistentId/versions/:latest?persistentId=doi:10.5072/FK2/BCCP9Z | jq '.data | {metadataBlocks: .metadataBlocks}' > dataset-update-metadata.json Now that the resulting JSON file only contains the ``metadataBlocks`` key, you can edit the JSON such as with ``vi`` in the example below::