From 140f792d81c6683f2193d26a3a0c5f8a44bbac0c Mon Sep 17 00:00:00 2001 From: Stefan Kasberger Date: Wed, 25 May 2022 12:21:09 +0200 Subject: [PATCH 01/40] update matomo to new instance --- .../docs/source/_templates/layout.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pyDataverse/docs/source/_templates/layout.html b/src/pyDataverse/docs/source/_templates/layout.html index dc7ee50..5080fdd 100644 --- a/src/pyDataverse/docs/source/_templates/layout.html +++ b/src/pyDataverse/docs/source/_templates/layout.html @@ -1,17 +1,17 @@ {% extends "!layout.html" %} {% block extrahead %} - From d5203a4ad70569b2e5e9e2862419aaf748dee1af Mon Sep 17 00:00:00 2001 From: Stefan Kasberger Date: Wed, 25 May 2022 12:50:07 +0200 Subject: [PATCH 02/40] update matomo to new instance --- src/pyDataverse/docs/source/_templates/layout.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pyDataverse/docs/source/_templates/layout.html b/src/pyDataverse/docs/source/_templates/layout.html index 5080fdd..83185b0 100644 --- a/src/pyDataverse/docs/source/_templates/layout.html +++ b/src/pyDataverse/docs/source/_templates/layout.html @@ -1,17 +1,17 @@ {% extends "!layout.html" %} {% block extrahead %} - From 5660044bc9b642f6ef3a3cb0f67d940ac8d54642 Mon Sep 17 00:00:00 2001 From: Stefan Kasberger Date: Wed, 25 May 2022 12:57:57 +0200 Subject: [PATCH 03/40] update matomo to new instance --- .../docs/source/_templates/layout.html | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/pyDataverse/docs/source/_templates/layout.html b/src/pyDataverse/docs/source/_templates/layout.html index 83185b0..24d07fb 100644 --- a/src/pyDataverse/docs/source/_templates/layout.html +++ b/src/pyDataverse/docs/source/_templates/layout.html @@ -1,18 +1,18 @@ {% extends "!layout.html" %} {% block extrahead %} - - - + + + {% endblock %} From c66fb365ef3a5945a5c8dc139bd9fd4da7abc948 Mon Sep 17 00:00:00 2001 From: Stefan Kasberger Date: Wed, 25 May 2022 13:09:30 +0200 Subject: [PATCH 04/40] update matomo to new instance --- src/pyDataverse/docs/source/_templates/layout.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyDataverse/docs/source/_templates/layout.html b/src/pyDataverse/docs/source/_templates/layout.html index 24d07fb..8cb52a7 100644 --- a/src/pyDataverse/docs/source/_templates/layout.html +++ b/src/pyDataverse/docs/source/_templates/layout.html @@ -7,7 +7,7 @@ _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function () { - var u = "http://piwik.stefankasberger.at/"; + var u = "//piwik.stefankasberger.at/"; _paq.push(['setTrackerUrl', u + 'matomo.php']); _paq.push(['setSiteId', '47']); var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0]; From acb02057ceb0d4dff185563e9ec6ea7877ff792c Mon Sep 17 00:00:00 2001 From: Stefan Kasberger Date: Tue, 30 Aug 2022 10:13:39 +0200 Subject: [PATCH 05/40] add repo status badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 0b02de6..fd80455 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ # pyDataverse +[![Project Status: Unsupported – The project has reached a stable, usable state but the author(s) have ceased all work on it. A new maintainer may be desired.](https://www.repostatus.org/badges/latest/unsupported.svg)](https://www.repostatus.org/#unsupported) + pyDataverse is a Python module for [Dataverse](http://dataverse.org). It helps to access the Dataverse [API's](http://guides.dataverse.org/en/latest/api/index.html) and manipulate, validate, import and export all Dataverse data-types (Dataverse, Dataset, Datafile). From 67a6c7e488ab1def523e358ee27332cbf9fce799 Mon Sep 17 00:00:00 2001 From: Stefan Kasberger Date: Tue, 30 Aug 2022 10:21:59 +0200 Subject: [PATCH 06/40] add repo status to docs --- src/pyDataverse/docs/source/index.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pyDataverse/docs/source/index.rst b/src/pyDataverse/docs/source/index.rst index 181f0b7..7653f12 100644 --- a/src/pyDataverse/docs/source/index.rst +++ b/src/pyDataverse/docs/source/index.rst @@ -51,6 +51,10 @@ basic API calls: pyDataverse is fully Open Source and can be used by everybody. +Project Status: Unsupported – The project has reached a stable, usable state but the author(s) have ceased all work on it. A new maintainer may be desired. + +pyDataverse is not supported right now. A new maintainer or funding is desired. Please contact the author , if you want to contribute in some way. + .. _homepage_install: Install From 5ffc52ca5475b4adfe6bf04d793b68efc3bbc3a4 Mon Sep 17 00:00:00 2001 From: Stefan Kasberger Date: Tue, 30 Aug 2022 10:27:40 +0200 Subject: [PATCH 07/40] fix docs issue --- src/pyDataverse/docs/source/index.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pyDataverse/docs/source/index.rst b/src/pyDataverse/docs/source/index.rst index 7653f12..8252b81 100644 --- a/src/pyDataverse/docs/source/index.rst +++ b/src/pyDataverse/docs/source/index.rst @@ -51,9 +51,11 @@ basic API calls: pyDataverse is fully Open Source and can be used by everybody. -Project Status: Unsupported – The project has reached a stable, usable state but the author(s) have ceased all work on it. A new maintainer may be desired. +.. image:: https://www.repostatus.org/badges/latest/unsupported.svg + :alt: Project Status: Unsupported – The project has reached a stable, usable state but the author(s) have ceased all work on it. A new maintainer may be desired. + :target: https://www.repostatus.org/#unsupported -pyDataverse is not supported right now. A new maintainer or funding is desired. Please contact the author , if you want to contribute in some way. +pyDataverse is not supported right now. A new maintainer or funding is desired. Please contact the author `Stefan Kasberger `_, if you want to contribute in some way. .. _homepage_install: From 47ce1122a5eaa0378674832da87ba05f349faa92 Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Thu, 2 Nov 2023 12:48:12 -0400 Subject: [PATCH 08/40] updated README with /api/admin endpoints --- README.md | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fd80455..a58ce15 100644 --- a/README.md +++ b/README.md @@ -7,4 +7,47 @@ pyDataverse is a Python module for [Dataverse](http://dataverse.org). It helps to access the Dataverse [API's](http://guides.dataverse.org/en/latest/api/index.html) and manipulate, validate, import and export all Dataverse data-types (Dataverse, Dataset, Datafile). -**Find out more: [Read the Docs](https://pydataverse.readthedocs.io/en/latest/)** +**Find out more: [pyDataverse Documentation](https://pydataverse.readthedocs.io/en/latest/)** + +----- + +/api/admin endpoints: +- [ ] .../settings +- [ ] .../settings/$name +- [ ] .../bannerMessage +- [ ] .../authenticationProviderFactories +- [ ] .../authenticationProviders +- [ ] .../authenticationProviders/$id/ +- [ ] .../authenticationProviders/$id/enabled +- [ ] .../roles +- [ ] .../roles/$id +- [ ] .../list-users + - [ ] searchTerm + - [ ] itemsPerPage + - [ ] selectedPage + - [ ] sortKey +- [ ] .../authenticatedUsers/$identifier +- [ ] .../authenticatedUsers +- [ ] merge user accounts +- [ ] change user identifier +- [ ] .../superuser/$identifier +- [ ] .../authenticatedUsers/$identifier +- [ ] .../authenticatedUsers/$USERNAME/deactivate +- [ ] GET /api/users/$USERNAME/traces +- [ ] POST /api/users/$USERNAME/removeRoles +- [ ] .../assignments/assignees/$identifier +- [ ] .../permissions/$identifier +- [ ] .../assignee/$identifier +- [ ] .../savedsearches +- [ ] .../savedsearches/makelinks +- [ ] .../datasets/integrity +- [ ] .../computeDataFileHashValue +- [ ] .../validate/dataset/files/{datasetId} +- [ ] .../validate/datasets +- [ ] .../workflows +- [ ] .../workflows/$id +- [ ] .../workflows/default +- [ ] .../workflows/ip-whitelist +- [ ] .../clearMetricsCache +- [ ] .../dataverse/{dataverse alias}/addRoleAssignmentsToChildren +- [ ] /api/licenses From 57f7a07fbad7494a50a76cc3dff7aaa7f573f535 Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Fri, 3 Nov 2023 14:42:34 -0400 Subject: [PATCH 09/40] get_setting() and get_settings() added --- src/pyDataverse/api.py | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index 22aeefe..35668ca 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2284,6 +2284,40 @@ def restrict_datafile(self, identifier: str, is_pid: bool = False) -> Response: url = f"{self.base_url_api_native}/files/{identifier}/restrict" return self.put_request(url, auth=True) + def get_settings(self): + """Get Dataverse settings. + + https://guides.dataverse.org/en/latest/api/native-api.html#list-all-database-settings + + Parameters: + ---------- + None. + + + Returns + ------- + requests.Response + Response object of requests library. + """ + + url = f"{self.base_url}api/admin/settings" + return self.get_request(url, auth=True) + + def get_setting(self, setting): + """Get a named setting. + + Parameters: + ---------- + setting: str + Name of a setting to retrieve. + + Returns + ------- + requests.Response + Response object of requests library. + """ + url = f"{self.base_url}api/admin/settings/{setting}" + return self.get_request(url, auth=True) class SearchApi(Api): """Class to access Dataverse's Search API. @@ -2291,7 +2325,7 @@ class SearchApi(Api): Examples ------- Examples should be written in doctest format, and - should illustrate how to use the function/class. + should illustrate how to use the function/c@lass. >>> Attributes From 4d6ff60507bcc15fa9134af4bc5731629b0f8aca Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Fri, 3 Nov 2023 15:25:59 -0400 Subject: [PATCH 10/40] no auth neccessary for get_setting() and get_settings() --- src/pyDataverse/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index 35668ca..8a8b57a 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2301,7 +2301,7 @@ def get_settings(self): """ url = f"{self.base_url}api/admin/settings" - return self.get_request(url, auth=True) + return self.get_request(url) def get_setting(self, setting): """Get a named setting. @@ -2317,7 +2317,7 @@ def get_setting(self, setting): Response object of requests library. """ url = f"{self.base_url}api/admin/settings/{setting}" - return self.get_request(url, auth=True) + return self.get_request(url) class SearchApi(Api): """Class to access Dataverse's Search API. From 6d91caf1b0bc8744493bdc801820333c63b02597 Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Fri, 3 Nov 2023 15:27:43 -0400 Subject: [PATCH 11/40] README updated for get_settings() and get_setting() --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a58ce15..57f61b7 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@ It helps to access the Dataverse [API's](http://guides.dataverse.org/en/latest/a ----- /api/admin endpoints: -- [ ] .../settings -- [ ] .../settings/$name +- [x] .../settings +- [x] .../settings/$name - [ ] .../bannerMessage - [ ] .../authenticationProviderFactories - [ ] .../authenticationProviders From df0e9e2a16058d2b740eb7ccbe336e25602c098e Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Fri, 3 Nov 2023 16:09:02 -0400 Subject: [PATCH 12/40] added list_auth_provider_factories() --- README.md | 2 +- src/pyDataverse/api.py | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 57f61b7..3023cfa 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ It helps to access the Dataverse [API's](http://guides.dataverse.org/en/latest/a - [x] .../settings - [x] .../settings/$name - [ ] .../bannerMessage -- [ ] .../authenticationProviderFactories +- [x] .../authenticationProviderFactories - [ ] .../authenticationProviders - [ ] .../authenticationProviders/$id/ - [ ] .../authenticationProviders/$id/enabled diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index 8a8b57a..80b7779 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2289,7 +2289,7 @@ def get_settings(self): https://guides.dataverse.org/en/latest/api/native-api.html#list-all-database-settings - Parameters: + Parameters ---------- None. @@ -2306,7 +2306,7 @@ def get_settings(self): def get_setting(self, setting): """Get a named setting. - Parameters: + Parameters ---------- setting: str Name of a setting to retrieve. @@ -2319,6 +2319,22 @@ def get_setting(self, setting): url = f"{self.base_url}api/admin/settings/{setting}" return self.get_request(url) + def list_auth_provider_factories(self): + """List the authentication provider factories. + + Parameters + ---------- + None. + + Returns + ------- + requests.Response + Response object of requests library. + """ + url = f"{self.base_url}api/admin/authenticationProviderFactories" + return self.get_request(url) + + class SearchApi(Api): """Class to access Dataverse's Search API. From 299a3d9b00aabb0aabcb1fccdc94b1ad6a4f351d Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Thu, 9 Nov 2023 15:28:25 -0500 Subject: [PATCH 13/40] delete_setting(setting) added --- src/pyDataverse/api.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index 80b7779..0e0698b 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2319,6 +2319,22 @@ def get_setting(self, setting): url = f"{self.base_url}api/admin/settings/{setting}" return self.get_request(url) + def delete_setting(self, setting): + """Delete a named setting + Parameters + ---------- + setting: str + Name of a setting to delete. + + Returns + ------- + requests.Response + Response object of requests library. + """ + url = f"{self.base_url}api/admin/settings/{setting}" + return delete_request(url) + + def list_auth_provider_factories(self): """List the authentication provider factories. @@ -2334,6 +2350,19 @@ def list_auth_provider_factories(self): url = f"{self.base_url}api/admin/authenticationProviderFactories" return self.get_request(url) + def list_users(self, searchTerm, itemsPerPage, selectedPage, sortKey): + """List the users. + + Parameters + ---------- + searchTerm + + itemsPerPage + selectedPage + sortKey + """ + url = f"{self.base_url}" + class SearchApi(Api): """Class to access Dataverse's Search API. From 94cec791167247e2e41e02ffc2193b4e415965cc Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Thu, 9 Nov 2023 16:05:20 -0500 Subject: [PATCH 14/40] add list_role_assignments(identifier) --- src/pyDataverse/api.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index 0e0698b..7d42cf7 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2320,7 +2320,8 @@ def get_setting(self, setting): return self.get_request(url) def delete_setting(self, setting): - """Delete a named setting + """Delete a named setting. + Parameters ---------- setting: str @@ -2334,6 +2335,23 @@ def delete_setting(self, setting): url = f"{self.base_url}api/admin/settings/{setting}" return delete_request(url) + def list_role_assignments(self, identifier): + """List role assignments of an assignee + + https://guides.dataverse.org/en/latest/api/native-api.html#list-role-assignments-of-a-role-assignee + + Parameters + ---------- + identifier: str + Identifier of an assignee. May contain slashes (&ip/localhost-users) + + Returns + ------- + requests.Response + Response object of a requests library. + """ + url = f"{self.base_url}api/admin/assignee/{assignee}" + return get_request(url) def list_auth_provider_factories(self): """List the authentication provider factories. From ed68062cd5089c795aa45033e86b1927d39cc621 Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Thu, 9 Nov 2023 16:23:59 -0500 Subject: [PATCH 15/40] add list_user(identifier) --- src/pyDataverse/api.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index 7d42cf7..f9623d6 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2368,6 +2368,25 @@ def list_auth_provider_factories(self): url = f"{self.base_url}api/admin/authenticationProviderFactories" return self.get_request(url) + + def list_user(self, identifier): + """List the user passed in. + + https://guides.dataverse.org/en/latest/api/native-api.html#list-single-user + + Parameters + ---------- + identifier: str + Identifier of the user. + + Returns + ------- + requests.Response object + """ + url = f"{self.base_url}api/admin/authenticatedUsers/{identifier}" + return self.get_request(url) + + def list_users(self, searchTerm, itemsPerPage, selectedPage, sortKey): """List the users. @@ -2379,7 +2398,7 @@ def list_users(self, searchTerm, itemsPerPage, selectedPage, sortKey): selectedPage sortKey """ - url = f"{self.base_url}" + class SearchApi(Api): From deb3c54c36a2970959890ceeaba5998da269d351 Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Wed, 15 Nov 2023 15:41:38 -0500 Subject: [PATCH 16/40] list_role_assignments(), show_role_assignee() --- README.md | 4 ++-- src/pyDataverse/api.py | 28 +++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3023cfa..cf639ab 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,9 @@ It helps to access the Dataverse [API's](http://guides.dataverse.org/en/latest/a - [ ] .../authenticatedUsers/$USERNAME/deactivate - [ ] GET /api/users/$USERNAME/traces - [ ] POST /api/users/$USERNAME/removeRoles -- [ ] .../assignments/assignees/$identifier +- [x] .../assignments/assignees/$identifier - [ ] .../permissions/$identifier -- [ ] .../assignee/$identifier +- [x] .../assignee/$identifier - [ ] .../savedsearches - [ ] .../savedsearches/makelinks - [ ] .../datasets/integrity diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index f9623d6..4a76c03 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2336,10 +2336,25 @@ def delete_setting(self, setting): return delete_request(url) def list_role_assignments(self, identifier): - """List role assignments of an assignee + """List all role assignments of an assignee (i.e. user or group) - https://guides.dataverse.org/en/latest/api/native-api.html#list-role-assignments-of-a-role-assignee + Parameters + ---------- + identifier: str + Identifier of a role assignee. + + Returns + ------- + requests.Response + Response object of the requests library. + """ + url = f"{self.base_url}api/admin/assignments/assignees/{identifier}" + return get_request(url) + def show_role_assignee(self, identifier): + """List a role assignee. + + https://guides.dataverse.org/en/latest/api/native-api.html#show-role-assignee Parameters ---------- identifier: str @@ -2348,11 +2363,13 @@ def list_role_assignments(self, identifier): Returns ------- requests.Response - Response object of a requests library. + Response object of the requests library. """ - url = f"{self.base_url}api/admin/assignee/{assignee}" + url = f"{self.base_url}api/admin/assignee/{identifier}" return get_request(url) + + def list_auth_provider_factories(self): """List the authentication provider factories. @@ -2398,7 +2415,8 @@ def list_users(self, searchTerm, itemsPerPage, selectedPage, sortKey): selectedPage sortKey """ - + url = f"{self.base_url}api/admin/" + return self.get_request(url) class SearchApi(Api): From 6d958e068bb59380e3a501f06a6a58926de3b29a Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Wed, 15 Nov 2023 15:56:11 -0500 Subject: [PATCH 17/40] list_permissions() --- README.md | 2 +- src/pyDataverse/api.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cf639ab..60afc15 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ It helps to access the Dataverse [API's](http://guides.dataverse.org/en/latest/a - [ ] GET /api/users/$USERNAME/traces - [ ] POST /api/users/$USERNAME/removeRoles - [x] .../assignments/assignees/$identifier -- [ ] .../permissions/$identifier +- [x] .../permissions/$identifier - [x] .../assignee/$identifier - [ ] .../savedsearches - [ ] .../savedsearches/makelinks diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index 4a76c03..82e1832 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2338,6 +2338,8 @@ def delete_setting(self, setting): def list_role_assignments(self, identifier): """List all role assignments of an assignee (i.e. user or group) + https://guides.dataverse.org/en/latest/api/native-api.html#list-role-assignments-of-a-role-assignee + Parameters ---------- identifier: str @@ -2351,10 +2353,30 @@ def list_role_assignments(self, identifier): url = f"{self.base_url}api/admin/assignments/assignees/{identifier}" return get_request(url) + def list_permissions(self, identifier) + """List Permissions a User Has on a Dataverse Collection or + Dataset. + + https://guides.dataverse.org/en/latest/api/native-api.html#list-permissions-a-user-has-on-a-dataverse-collection-or-dataset + + Parameters + ---------- + identifier: str + collection alias, database id, dataset persistent ID, or database id. + + Returns + ------- + requests.Response + Response object of the requests library. + """ + url = f"{self.base_url}api/admin/permissions/{identifier}" + return get_request(url) + def show_role_assignee(self, identifier): """List a role assignee. https://guides.dataverse.org/en/latest/api/native-api.html#show-role-assignee + Parameters ---------- identifier: str From aeb48ec9d30d26ea786010084c3b00e6b9a8d5fa Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Wed, 15 Nov 2023 16:13:26 -0500 Subject: [PATCH 18/40] reorder --- src/pyDataverse/api.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index 82e1832..c5cfa7f 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2335,6 +2335,21 @@ def delete_setting(self, setting): url = f"{self.base_url}api/admin/settings/{setting}" return delete_request(url) + def list_auth_provider_factories(self): + """List the authentication provider factories. + + Parameters + ---------- + None. + + Returns + ------- + requests.Response + Response object of requests library. + """ + url = f"{self.base_url}api/admin/authenticationProviderFactories" + return self.get_request(url) + def list_role_assignments(self, identifier): """List all role assignments of an assignee (i.e. user or group) @@ -2392,20 +2407,6 @@ def show_role_assignee(self, identifier): - def list_auth_provider_factories(self): - """List the authentication provider factories. - - Parameters - ---------- - None. - - Returns - ------- - requests.Response - Response object of requests library. - """ - url = f"{self.base_url}api/admin/authenticationProviderFactories" - return self.get_request(url) def list_user(self, identifier): From 1d9f6b80ce07993abe5d0ed38edaa8170238c84f Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Wed, 15 Nov 2023 16:14:21 -0500 Subject: [PATCH 19/40] docstring fix --- src/pyDataverse/api.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index c5cfa7f..993f814 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2338,6 +2338,8 @@ def delete_setting(self, setting): def list_auth_provider_factories(self): """List the authentication provider factories. + https://guides.dataverse.org/en/latest/api/native-api.html#list-authentication-provider-factories + Parameters ---------- None. From 0fc1f8b02d26f6183ec86cbf136e1a15f35d3d8d Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Thu, 16 Nov 2023 10:24:16 -0500 Subject: [PATCH 20/40] list_auth_providers(), add_auth_provider(), show_auth_provider() --- src/pyDataverse/api.py | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index 993f814..76792dd 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2352,6 +2352,59 @@ def list_auth_provider_factories(self): url = f"{self.base_url}api/admin/authenticationProviderFactories" return self.get_request(url) + def list_auth_providers(self): + """List the authentication providers. + + https://guides.dataverse.org/en/latest/api/native-api.html#list-authentication-providers + + Parameters + ---------- + None. + + Returns + ------- + requests.Response + Response object of requests library. + """ + url = f"{base_url}api/admin/authenticationProviders" + return get_request(url) + + def add_auth_provider(self, authProviderJSON): + """Add an authentication provider. + + https://guides.dataverse.org/en/latest/api/native-api.html#add-authentication-provider + Parameters + ---------- + jsonData: str + JSON object describing an authentication provider + + Returns + ------- + requests.Response + Response object of requests library. + """ + url = f"{base_url}api/admin/authenticationProviders" + return post_request(url, data=authProviderJSON) + + def show_auth_provider(self, identifier): + """Show information about an authentication provider. + + https://guides.dataverse.org/en/latest/api/native-api.html#show-authentication-provider + + Parameters + ---------- + identifier: str + An authentication provider + + Returns + ------- + requests.Response + Response object of requests library. + """ + url = f"{base_url}api/admin/authenticationProvider/{identifier}" + return get_request(url) + + def list_role_assignments(self, identifier): """List all role assignments of an assignee (i.e. user or group) From b0b36e13a4f37a6ca0257ed5b8281e9fedca86e5 Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Thu, 16 Nov 2023 10:24:38 -0500 Subject: [PATCH 21/40] update README to current status --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 60afc15..7d3f407 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,18 @@ It helps to access the Dataverse [API's](http://guides.dataverse.org/en/latest/a /api/admin endpoints: - [x] .../settings + - [x] get_settings() + - [x] get_setting(setting) + - [x] delete_setting(setting) - [x] .../settings/$name - [ ] .../bannerMessage - [x] .../authenticationProviderFactories + - [x] list_auth_provider_factories() - [ ] .../authenticationProviders + - [x] list_auth_providers() + - [x] add_auth_provider(authProviderJSON) - [ ] .../authenticationProviders/$id/ + - [x] show_auth_provider(identifier) - [ ] .../authenticationProviders/$id/enabled - [ ] .../roles - [ ] .../roles/$id @@ -27,6 +34,7 @@ It helps to access the Dataverse [API's](http://guides.dataverse.org/en/latest/a - [ ] selectedPage - [ ] sortKey - [ ] .../authenticatedUsers/$identifier + - [x] list_user(identifier) - [ ] .../authenticatedUsers - [ ] merge user accounts - [ ] change user identifier @@ -36,8 +44,11 @@ It helps to access the Dataverse [API's](http://guides.dataverse.org/en/latest/a - [ ] GET /api/users/$USERNAME/traces - [ ] POST /api/users/$USERNAME/removeRoles - [x] .../assignments/assignees/$identifier + - [x] list_role_assignments(identifier) - [x] .../permissions/$identifier + - [x] list_permissions(identifier) - [x] .../assignee/$identifier + - [x] show_role_assignee(identifier) - [ ] .../savedsearches - [ ] .../savedsearches/makelinks - [ ] .../datasets/integrity From 151419ed4929ec9fea4821efb127f074e863f73b Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Thu, 16 Nov 2023 10:26:09 -0500 Subject: [PATCH 22/40] add URL of docs to docstrings --- src/pyDataverse/api.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index 76792dd..f7555db 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2306,6 +2306,8 @@ def get_settings(self): def get_setting(self, setting): """Get a named setting. + https://guides.dataverse.org/en/latest/api/native-api.html#get-single-database-setting + Parameters ---------- setting: str @@ -2322,6 +2324,8 @@ def get_setting(self, setting): def delete_setting(self, setting): """Delete a named setting. + https://guides.dataverse.org/en/latest/api/native-api.html#delete-database-setting + Parameters ---------- setting: str @@ -2460,10 +2464,6 @@ def show_role_assignee(self, identifier): url = f"{self.base_url}api/admin/assignee/{identifier}" return get_request(url) - - - - def list_user(self, identifier): """List the user passed in. @@ -2481,7 +2481,7 @@ def list_user(self, identifier): url = f"{self.base_url}api/admin/authenticatedUsers/{identifier}" return self.get_request(url) - + # XXX - TODO def list_users(self, searchTerm, itemsPerPage, selectedPage, sortKey): """List the users. From c311f31b6d4cbe6851eb2201ad7a4da3d2cd33b5 Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Thu, 16 Nov 2023 11:16:17 -0500 Subject: [PATCH 23/40] add complete admin api to README --- README.md | 79 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 61 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 7d3f407..086663c 100644 --- a/README.md +++ b/README.md @@ -12,37 +12,47 @@ It helps to access the Dataverse [API's](http://guides.dataverse.org/en/latest/a ----- /api/admin endpoints: -- [x] .../settings +- [ ] .../settings, .../settings/$name - [x] get_settings() - [x] get_setting(setting) - [x] delete_setting(setting) -- [x] .../settings/$name + - [ ] configure_setting(name, value) - [ ] .../bannerMessage + - [ ] add_banner_message(messages_JSON) + - [ ] show_banner_messages() + - [ ] delete_banner_message(id) + - [ ] deactive_banner_message(id) - [x] .../authenticationProviderFactories - [x] list_auth_provider_factories() - [ ] .../authenticationProviders - [x] list_auth_providers() - [x] add_auth_provider(authProviderJSON) -- [ ] .../authenticationProviders/$id/ - [x] show_auth_provider(identifier) -- [ ] .../authenticationProviders/$id/enabled + - [ ] enable_auth_provider(id) + - [ ] disable_auth_provider(id) + - [ ] check_auth_provider_enabled(id) + - [ ] delete_auth_provider - [ ] .../roles -- [ ] .../roles/$id + - [ ] list_global_roles() + - [ ] create_global_role(roles_JSON) + - [ ] delete_global_role(id) - [ ] .../list-users - - [ ] searchTerm - - [ ] itemsPerPage - - [ ] selectedPage - - [ ] sortKey -- [ ] .../authenticatedUsers/$identifier - - [x] list_user(identifier) + - [ ] list_users(searchTerm, itemsPerPage, selectedPage, sortKey) - [ ] .../authenticatedUsers + - [x] list_user(identifier) + - [ ] create_user(userJSON) + - [ ] delete_user(id) + - [ ] deactivate_user(id) - [ ] merge user accounts + - [ ] merge_users(user_merged_into, user_to_merge_and_delete) - [ ] change user identifier + - [ ] change_user_identifier(oldId, newId) - [ ] .../superuser/$identifier -- [ ] .../authenticatedUsers/$identifier -- [ ] .../authenticatedUsers/$USERNAME/deactivate + - [ ] superuser_toggle(userId) - [ ] GET /api/users/$USERNAME/traces + - [ ] show_user_traces(username) - [ ] POST /api/users/$USERNAME/removeRoles + - [ ] remove_all_roles(username) - [x] .../assignments/assignees/$identifier - [x] list_role_assignments(identifier) - [x] .../permissions/$identifier @@ -50,15 +60,48 @@ It helps to access the Dataverse [API's](http://guides.dataverse.org/en/latest/a - [x] .../assignee/$identifier - [x] show_role_assignee(identifier) - [ ] .../savedsearches -- [ ] .../savedsearches/makelinks + - [ ] list_searches() + - [ ] list_search(id) + - [ ] execute_search(id) - [ ] .../datasets/integrity + - [ ] calculate_unf(datasetVerId) - [ ] .../computeDataFileHashValue + - [ ] calculate_datafile_checksum(fileId) + - [ ] validate_current_datafile_checksum(fileId) - [ ] .../validate/dataset/files/{datasetId} -- [ ] .../validate/datasets + - [ ] validate_dataset_files(datasetId) +- [ ] .../updateHashValues(algorithm, batch_size) + - [ ] update_dataset_hashes(datasetId) - [ ] .../workflows -- [ ] .../workflows/$id -- [ ] .../workflows/default -- [ ] .../workflows/ip-whitelist + - [ ] list_workflows() + - [ ] show_workflow(id) + - [ ] add_workflow(workflowJSON) + - [ ] delete_workflow(id) + - [ ] list_default_workflow() + - [ ] set_default_workflow(workflow_id, workflow_trigger) + - [ ] unset_default_workflow(trigger_type) + - [ ] set_workflow_allowed_ip(allowed_list) + - [ ] get_workflow_allowed_ip() + - [ ] restore_workflow_default_allowed_ip() - [ ] .../clearMetricsCache + - [ ] clear_cached_metrics() + - [ ] clear_metric_cache(metric_db_name) - [ ] .../dataverse/{dataverse alias}/addRoleAssignmentsToChildren + - [ ] inherit_role_assignments(datavserse) - [ ] /api/licenses + - [ ] view_licenses_available() + - [ ] view_dataset_license(id) + - [ ] add_dataset_license(licenseJSON) + - [ ] set_dataset_license() + - [ ] delete_dataset_license(id) + - [ ] set_dataset_license_sort(id, sort_order) +- [ ] .../templates + - [ ] list_templates() + - [ ] list_templates(id) + - [ ] delete_template(id) +- [ ] .../requestSignedUrl + - [ ] request_signed_url(url, timeout, http_method, user) +- [ ] .../feedback + - [ ] send_feedback(feedbackJSON) +- [ ] .../mydata + - [ ] list_data(role_id, dv_object_type, published_states, per_page) From f0bd21ec9427b6ffb08b3f14c298c0571e50daf7 Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Thu, 16 Nov 2023 12:44:20 -0500 Subject: [PATCH 24/40] configure_setting() --- README.md | 5 +++-- src/pyDataverse/api.py | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 086663c..3736a5a 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,14 @@ It helps to access the Dataverse [API's](http://guides.dataverse.org/en/latest/a **Find out more: [pyDataverse Documentation](https://pydataverse.readthedocs.io/en/latest/)** ----- +Implementated methods for /api/admin: /api/admin endpoints: -- [ ] .../settings, .../settings/$name +- [x] .../settings, .../settings/$name - [x] get_settings() - [x] get_setting(setting) + - [x] configure_setting(name, value) - [x] delete_setting(setting) - - [ ] configure_setting(name, value) - [ ] .../bannerMessage - [ ] add_banner_message(messages_JSON) - [ ] show_banner_messages() diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index f7555db..9a52a9b 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2321,6 +2321,25 @@ def get_setting(self, setting): url = f"{self.base_url}api/admin/settings/{setting}" return self.get_request(url) + def configure_setting(self, setting, value): + """Configure a setting. + + https://guides.dataverse.org/en/latest/api/native-api.html#configure-database-setting + Parameters + ---------- + setting: str + Name of a setting to change. + value: str + Value the setting should have after the change. + + Returns + ------- + requests.Response + Response object of requests library. + """ + url = f"{self.base_url}api/admin/settings/{setting}" + return self.put_request(url, value) + def delete_setting(self, setting): """Delete a named setting. From ebe1448397f77e058d37bb694409c2173427587f Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Thu, 16 Nov 2023 12:52:30 -0500 Subject: [PATCH 25/40] list_users() cleaned up and disabled --- src/pyDataverse/api.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index 9a52a9b..d7502ec 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2427,7 +2427,6 @@ def show_auth_provider(self, identifier): url = f"{base_url}api/admin/authenticationProvider/{identifier}" return get_request(url) - def list_role_assignments(self, identifier): """List all role assignments of an assignee (i.e. user or group) @@ -2504,16 +2503,25 @@ def list_user(self, identifier): def list_users(self, searchTerm, itemsPerPage, selectedPage, sortKey): """List the users. + Output is paginated by default, in this implementation. + Parameters ---------- - searchTerm - - itemsPerPage - selectedPage - sortKey - """ - url = f"{self.base_url}api/admin/" - return self.get_request(url) + searchTerm: str + String describing the search. + itemsPerPage: int + Number of items to display for each page. + selectedPage: int + Page number of results to show. + sortKey: str + How to sort results, before pagination + """ + # TODO - XXXX + # construct query URL using urllib + # + #url = f"{self.base_url}api/admin/list-users/" + #return self.get_request(url) + pass class SearchApi(Api): From 04fd82e3b300bd9ce270e6224ce4dec487a8e060 Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Thu, 16 Nov 2023 12:57:31 -0500 Subject: [PATCH 26/40] list_global_roles() --- README.md | 2 +- src/pyDataverse/api.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3736a5a..e7ac74d 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Implementated methods for /api/admin: - [ ] check_auth_provider_enabled(id) - [ ] delete_auth_provider - [ ] .../roles - - [ ] list_global_roles() + - [x] list_global_roles() - [ ] create_global_role(roles_JSON) - [ ] delete_global_role(id) - [ ] .../list-users diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index d7502ec..a76db55 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2427,6 +2427,23 @@ def show_auth_provider(self, identifier): url = f"{base_url}api/admin/authenticationProvider/{identifier}" return get_request(url) + def list_global_roles(self): + """List all global roles in the system. + + https://guides.dataverse.org/en/latest/api/native-api.html#list-global-roles + + Parameters + ---------- + None. + + Returns + ------- + requests.Response + Response object of requests library. + """ + url = f"{base_url}api/admin/roles" + return get_request(url) + def list_role_assignments(self, identifier): """List all role assignments of an assignee (i.e. user or group) From a70ab869ba44e6607a967e349b552682bcd73426 Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Thu, 16 Nov 2023 13:03:44 -0500 Subject: [PATCH 27/40] create_global_role() --- README.md | 3 ++- src/pyDataverse/api.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e7ac74d..48e35ab 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,8 @@ It helps to access the Dataverse [API's](http://guides.dataverse.org/en/latest/a **Find out more: [pyDataverse Documentation](https://pydataverse.readthedocs.io/en/latest/)** ----- -Implementated methods for /api/admin: +Implementated methods for /api/admin. These methods are implemented. They +do not validate input (such as JSON objects), and do not yet have testcases. /api/admin endpoints: - [x] .../settings, .../settings/$name diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index a76db55..d088ad2 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2444,6 +2444,24 @@ def list_global_roles(self): url = f"{base_url}api/admin/roles" return get_request(url) + def create_global_role(self, roles_json): + """Create a global role. + + https://guides.dataverse.org/en/latest/api/native-api.html#create-global-role + + Parameters + ---------- + roles_json: str + JSON object describing the role. + + Returns + ------- + requests.Response + Response object of requests library. + """ + url = f"{base_url}api/admin/roles" + return post_request(url, roles_json) + def list_role_assignments(self, identifier): """List all role assignments of an assignee (i.e. user or group) From 3fa711ddb37efe084116904e9b884f3ab54427b3 Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Thu, 16 Nov 2023 13:26:17 -0500 Subject: [PATCH 28/40] update README + comments --- README.md | 2 +- src/pyDataverse/api.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 48e35ab..617ee78 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ do not validate input (such as JSON objects), and do not yet have testcases. - [ ] delete_auth_provider - [ ] .../roles - [x] list_global_roles() - - [ ] create_global_role(roles_JSON) + - [x] create_global_role(roles_JSON) - [ ] delete_global_role(id) - [ ] .../list-users - [ ] list_users(searchTerm, itemsPerPage, selectedPage, sortKey) diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index d088ad2..758d4ba 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2427,6 +2427,8 @@ def show_auth_provider(self, identifier): url = f"{base_url}api/admin/authenticationProvider/{identifier}" return get_request(url) + # description of roles: + # https://guides.dataverse.org/en/latest/api/native-api.html#json-representation-of-a-role def list_global_roles(self): """List all global roles in the system. From 687fdc997c7a609362d2cb58b2dc5d9f7f7443e7 Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Thu, 16 Nov 2023 13:30:59 -0500 Subject: [PATCH 29/40] delete_global_role(role) --- src/pyDataverse/api.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index 758d4ba..622174b 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2464,6 +2464,25 @@ def create_global_role(self, roles_json): url = f"{base_url}api/admin/roles" return post_request(url, roles_json) + def delete_global_role(self, role): + """Delete a global role. + + https://guides.dataverse.org/en/latest/api/native-api.html#delete-global-role + + Parameters + ---------- + role: str + Global role to be deleted. + + Returns + ------- + requests.Response + Response object of requests library. + """ + url = f"{base_url}api/admin/roles/{role}" + return delete_request(url) + + def list_role_assignments(self, identifier): """List all role assignments of an assignee (i.e. user or group) From 3b1801dd112e4bdcdc90debbe323b19eef6b748b Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Thu, 16 Nov 2023 13:31:48 -0500 Subject: [PATCH 30/40] README update for delete_global_role(role) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 617ee78..da8e91a 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,10 @@ do not validate input (such as JSON objects), and do not yet have testcases. - [ ] disable_auth_provider(id) - [ ] check_auth_provider_enabled(id) - [ ] delete_auth_provider -- [ ] .../roles +- [x] .../roles - [x] list_global_roles() - [x] create_global_role(roles_JSON) - - [ ] delete_global_role(id) + - [x] delete_global_role(id) - [ ] .../list-users - [ ] list_users(searchTerm, itemsPerPage, selectedPage, sortKey) - [ ] .../authenticatedUsers From 8e3edb3a3b56be446275fac48764a245994e5193 Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Thu, 16 Nov 2023 13:33:12 -0500 Subject: [PATCH 31/40] fix docstring --- src/pyDataverse/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index 622174b..3ccf941 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2472,7 +2472,7 @@ def delete_global_role(self, role): Parameters ---------- role: str - Global role to be deleted. + Identifier of the global role to be deleted. Returns ------- From c1d7548c8b48c9649d3f937ce72c042d3925d445 Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Thu, 16 Nov 2023 14:44:45 -0500 Subject: [PATCH 32/40] create_user(user_json) --- README.md | 2 +- src/pyDataverse/api.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index da8e91a..2d34667 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ do not validate input (such as JSON objects), and do not yet have testcases. - [ ] list_users(searchTerm, itemsPerPage, selectedPage, sortKey) - [ ] .../authenticatedUsers - [x] list_user(identifier) - - [ ] create_user(userJSON) + - [x] create_user(userJSON) - [ ] delete_user(id) - [ ] deactivate_user(id) - [ ] merge user accounts diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index 3ccf941..e4e94ca 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2579,6 +2579,23 @@ def list_users(self, searchTerm, itemsPerPage, selectedPage, sortKey): #return self.get_request(url) pass + def create_user(self, user_json): + """Create an authenticated user. + + https://guides.dataverse.org/en/latest/api/native-api.html#create-an-authenticated-user + + Parameters + ---------- + user_json: str + JSON object describing the new user. + + Returns + ------- + requests.Response + Response object of requests library. + """ + url = f"{base_url}api/admin/authenticatedUsers" + return post_request(url, user_json) class SearchApi(Api): """Class to access Dataverse's Search API. From 52464655bf2da3792e20630ebc85daab38a57b1e Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Thu, 16 Nov 2023 14:54:57 -0500 Subject: [PATCH 33/40] delete_auth_provider(id), check_auth_provider_enabled(id) --- README.md | 4 ++-- src/pyDataverse/api.py | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2d34667..56066b1 100644 --- a/README.md +++ b/README.md @@ -32,8 +32,8 @@ do not validate input (such as JSON objects), and do not yet have testcases. - [x] show_auth_provider(identifier) - [ ] enable_auth_provider(id) - [ ] disable_auth_provider(id) - - [ ] check_auth_provider_enabled(id) - - [ ] delete_auth_provider + - [x] check_auth_provider_enabled(id) + - [x] delete_auth_provider - [x] .../roles - [x] list_global_roles() - [x] create_global_role(roles_JSON) diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index e4e94ca..8d0946c 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2427,6 +2427,43 @@ def show_auth_provider(self, identifier): url = f"{base_url}api/admin/authenticationProvider/{identifier}" return get_request(url) + def check_auth_provider_enabled(self, identifier): + """Check if an authentication provider is enabled. + + https://guides.dataverse.org/en/latest/api/native-api.html#check-if-an-authentication-provider-is-enabled + + Parameters + ---------- + identifier: str + Authentication provider to check if enabled. + + Returns + ------- + requests.Response + Response object of requests library. + """ + url = f"{base_url}api/admin/authenticationProviders/{id}/enabled" + get_request(url) + + def delete_auth_provider(self, identifier): + """Deletes an authentication provider from the system. Always + succeeds. + + https://guides.dataverse.org/en/latest/api/native-api.html#delete-an-authentication-provider + + Paramters + --------- + identifier: str + Identifier of the authentication provider. + + Returns + ------- + requests.Response + Response object of requests library. + """ + url = f"{base_url}api/admin/roles/{identifier}" + return delete_request(url) + # description of roles: # https://guides.dataverse.org/en/latest/api/native-api.html#json-representation-of-a-role def list_global_roles(self): From c431f5e9dac374d1c73cfc58d5a9d723e008e20a Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Fri, 17 Nov 2023 10:31:27 -0500 Subject: [PATCH 34/40] merge_users(dest_acct, source_acct) --- README.md | 4 ++-- src/pyDataverse/api.py | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 56066b1..a2dea11 100644 --- a/README.md +++ b/README.md @@ -45,8 +45,8 @@ do not validate input (such as JSON objects), and do not yet have testcases. - [x] create_user(userJSON) - [ ] delete_user(id) - [ ] deactivate_user(id) -- [ ] merge user accounts - - [ ] merge_users(user_merged_into, user_to_merge_and_delete) +- [x] merge user accounts + - [x] merge_users(dest_acct, source_acct) - [ ] change user identifier - [ ] change_user_identifier(oldId, newId) - [ ] .../superuser/$identifier diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index 8d0946c..f4a97dd 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2634,6 +2634,31 @@ def create_user(self, user_json): url = f"{base_url}api/admin/authenticatedUsers" return post_request(url, user_json) + def merge_users(self, dest_acct, source_acct): + """Merge a source account into a destination account, and then delete the + source account. Accounts are only merged if both are active or + both are deactivated. + + https://guides.dataverse.org/en/latest/api/native-api.html#merge-user-accounts + + Parameters + ---------- + dest_acct: str + Account to be preserved. Contains the data from both accounts, + post-merge + source_acct: str + Account that will be merged into the other account. Deleted + after the merge. + + Returns + ------- + requests.Response object + Response object of requests library. + """ + url = f"{base_url}api/users/{source_acct}/mergeIntoUser/{dest_acct}" + post_request(url) + + class SearchApi(Api): """Class to access Dataverse's Search API. From cabf4c13ba517051491d4f6245a1bd4035c6f95b Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Fri, 17 Nov 2023 10:38:14 -0500 Subject: [PATCH 35/40] change_user_identifier(old_identifier, new_identifier) --- README.md | 4 ++-- src/pyDataverse/api.py | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a2dea11..4f352bf 100644 --- a/README.md +++ b/README.md @@ -47,8 +47,8 @@ do not validate input (such as JSON objects), and do not yet have testcases. - [ ] deactivate_user(id) - [x] merge user accounts - [x] merge_users(dest_acct, source_acct) -- [ ] change user identifier - - [ ] change_user_identifier(oldId, newId) +- [x] change user identifier + - [x] change_user_identifier(old_identifier, new_identifier) - [ ] .../superuser/$identifier - [ ] superuser_toggle(userId) - [ ] GET /api/users/$USERNAME/traces diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index f4a97dd..a726f36 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2658,6 +2658,28 @@ def merge_users(self, dest_acct, source_acct): url = f"{base_url}api/users/{source_acct}/mergeIntoUser/{dest_acct}" post_request(url) + def change_user_identifier(self, new_identifier, old_identifier): + """Changes identifier for user in AuthenticatedUser, BuiltinUser, + AuthenticatedUserLookup & RoleAssignment. Allows them to log in with the new + identifier. Only accessible to superusers. + + https://guides.dataverse.org/en/latest/api/native-api.html#change-user-identifier + + Parameters + ---------- + new_identifier: str + New identifier, that the user can user for login. + old_identifier: str + Old identifier, that user previously used for login. + + Returns + ------- + requests.Response object + Response object of requests library. + """ + url = + f"{base_url}api/users/{old_identifier}changeIdentifier/{new_identifier}" + post_request(url) class SearchApi(Api): """Class to access Dataverse's Search API. From e333b07c11ca8c1195c45e4149350bfe4e25398c Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Fri, 17 Nov 2023 10:42:37 -0500 Subject: [PATCH 36/40] superuser_toggle(identifier) --- README.md | 4 ++-- src/pyDataverse/api.py | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4f352bf..1115373 100644 --- a/README.md +++ b/README.md @@ -49,8 +49,8 @@ do not validate input (such as JSON objects), and do not yet have testcases. - [x] merge_users(dest_acct, source_acct) - [x] change user identifier - [x] change_user_identifier(old_identifier, new_identifier) -- [ ] .../superuser/$identifier - - [ ] superuser_toggle(userId) +- [x] .../superuser/$identifier + - [x] superuser_toggle(userId) - [ ] GET /api/users/$USERNAME/traces - [ ] show_user_traces(username) - [ ] POST /api/users/$USERNAME/removeRoles diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index a726f36..2f9018e 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2677,10 +2677,26 @@ def change_user_identifier(self, new_identifier, old_identifier): requests.Response object Response object of requests library. """ - url = - f"{base_url}api/users/{old_identifier}changeIdentifier/{new_identifier}" + url = f"{base_url}api/users/{old_identifier}changeIdentifier/{new_identifier}" post_request(url) + def superuser_toggle(self, identifier): + """Toggles superuser mode on the AuthenticatedUser whose identifier (without the @ sign) is passed. + + https://guides.dataverse.org/en/latest/api/native-api.html#make-user-a-superuser + + Parameters + ---------- + identifier: str + Account that will have superuser privileges added or revoked. + + Returns + ------- + requests.Response object + Response object of requests library. + """ + url = f"{base_url}api/admin/superuser/{identifier}" + class SearchApi(Api): """Class to access Dataverse's Search API. From 816db9b42707d6e8ad591fc0060e8b2d6ac0c1ed Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Fri, 17 Nov 2023 11:19:57 -0500 Subject: [PATCH 37/40] deactivate_user(identifier) --- README.md | 2 +- src/pyDataverse/api.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1115373..3475479 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ do not validate input (such as JSON objects), and do not yet have testcases. - [x] list_user(identifier) - [x] create_user(userJSON) - [ ] delete_user(id) - - [ ] deactivate_user(id) + - [x] deactivate_user(id) - [x] merge user accounts - [x] merge_users(dest_acct, source_acct) - [x] change user identifier diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index 2f9018e..7f44d01 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2697,6 +2697,28 @@ def superuser_toggle(self, identifier): """ url = f"{base_url}api/admin/superuser/{identifier}" + def deactivate_user(self, identifier): + """Deactivates a user. A superuser API token is not required but + the command will operate using the first superuser it finds. This + irreversible. + + https://guides.dataverse.org/en/latest/api/native-api.html#deactivate-a-user + + Please see the guide, for descriptions of deactivation. + + Parameters + ---------- + identifier: str + Account to deactivate. + + Returns + ------- + requests.Response object + Response object of requests library. + """ + url = f"{base_url}api/admin/authenticatedUsers/{identifier}/deactivate" + post_request(url) + class SearchApi(Api): """Class to access Dataverse's Search API. From 8bd72214f4cc7d8c17909719c6002bf0083daa1c Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Fri, 17 Nov 2023 11:23:58 -0500 Subject: [PATCH 38/40] remove_user_roles(identifier) --- README.md | 4 ++-- src/pyDataverse/api.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3475479..36a505e 100644 --- a/README.md +++ b/README.md @@ -53,8 +53,8 @@ do not validate input (such as JSON objects), and do not yet have testcases. - [x] superuser_toggle(userId) - [ ] GET /api/users/$USERNAME/traces - [ ] show_user_traces(username) -- [ ] POST /api/users/$USERNAME/removeRoles - - [ ] remove_all_roles(username) +- [x] POST /api/users/$USERNAME/removeRoles + - [x] remove_all_roles(username) - [x] .../assignments/assignees/$identifier - [x] list_role_assignments(identifier) - [x] .../permissions/$identifier diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index 7f44d01..4bac73d 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2575,6 +2575,24 @@ def show_role_assignee(self, identifier): url = f"{self.base_url}api/admin/assignee/{identifier}" return get_request(url) + def remove_user_roles(self, identifier): + """Removes all roles from the user. + + https://guides.dataverse.org/en/latest/api/native-api.html#remove-all-roles-from-a-user + + Parameters + ---------- + identifer: str + Account to have roles removed. + + Returns + ------- + requests.Response + Response object of the requests library. + """ + url = f"{base_url}api/users/{identifier}/removeRoles" + return post_request(url) + def list_user(self, identifier): """List the user passed in. From 499c93457de7028dc0871f90304a337e816910dd Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Fri, 17 Nov 2023 11:32:13 -0500 Subject: [PATCH 39/40] show_user_traces(identifier) --- README.md | 4 ++-- src/pyDataverse/api.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 36a505e..6674be4 100644 --- a/README.md +++ b/README.md @@ -51,8 +51,8 @@ do not validate input (such as JSON objects), and do not yet have testcases. - [x] change_user_identifier(old_identifier, new_identifier) - [x] .../superuser/$identifier - [x] superuser_toggle(userId) -- [ ] GET /api/users/$USERNAME/traces - - [ ] show_user_traces(username) +- [x] GET /api/users/$USERNAME/traces + - [x] show_user_traces(username) - [x] POST /api/users/$USERNAME/removeRoles - [x] remove_all_roles(username) - [x] .../assignments/assignees/$identifier diff --git a/src/pyDataverse/api.py b/src/pyDataverse/api.py index 4bac73d..b06bcb8 100644 --- a/src/pyDataverse/api.py +++ b/src/pyDataverse/api.py @@ -2575,6 +2575,24 @@ def show_role_assignee(self, identifier): url = f"{self.base_url}api/admin/assignee/{identifier}" return get_request(url) + def show_user_traces(self, identifier): + """Show the traces that the user has left in the system, such as datasets created, guestbooks filled out, etc. This can be useful for understanding why a user cannot be deleted. A superuser API token is required. + + https://guides.dataverse.org/en/latest/api/native-api.html#show-user-traces + + Parameters + ---------- + identifier: str + User that is queried to see their traces. + + Returns + ------- + requests.Response + Response object of the requests library. + """ + url = f"{base_url}api/users/{identifier}/traces" + return get_request(url) + def remove_user_roles(self, identifier): """Removes all roles from the user. From 72df2b78c31a5e17f7cf5cbea0ccf921ad3bc9ef Mon Sep 17 00:00:00 2001 From: Brian Brock Date: Thu, 30 Nov 2023 14:32:01 -0500 Subject: [PATCH 40/40] fix README --- README.md | 99 ------------------------------------------------------- 1 file changed, 99 deletions(-) diff --git a/README.md b/README.md index 6674be4..37871ec 100644 --- a/README.md +++ b/README.md @@ -8,102 +8,3 @@ pyDataverse is a Python module for [Dataverse](http://dataverse.org). It helps to access the Dataverse [API's](http://guides.dataverse.org/en/latest/api/index.html) and manipulate, validate, import and export all Dataverse data-types (Dataverse, Dataset, Datafile). **Find out more: [pyDataverse Documentation](https://pydataverse.readthedocs.io/en/latest/)** - ------ -Implementated methods for /api/admin. These methods are implemented. They -do not validate input (such as JSON objects), and do not yet have testcases. - -/api/admin endpoints: -- [x] .../settings, .../settings/$name - - [x] get_settings() - - [x] get_setting(setting) - - [x] configure_setting(name, value) - - [x] delete_setting(setting) -- [ ] .../bannerMessage - - [ ] add_banner_message(messages_JSON) - - [ ] show_banner_messages() - - [ ] delete_banner_message(id) - - [ ] deactive_banner_message(id) -- [x] .../authenticationProviderFactories - - [x] list_auth_provider_factories() -- [ ] .../authenticationProviders - - [x] list_auth_providers() - - [x] add_auth_provider(authProviderJSON) - - [x] show_auth_provider(identifier) - - [ ] enable_auth_provider(id) - - [ ] disable_auth_provider(id) - - [x] check_auth_provider_enabled(id) - - [x] delete_auth_provider -- [x] .../roles - - [x] list_global_roles() - - [x] create_global_role(roles_JSON) - - [x] delete_global_role(id) -- [ ] .../list-users - - [ ] list_users(searchTerm, itemsPerPage, selectedPage, sortKey) -- [ ] .../authenticatedUsers - - [x] list_user(identifier) - - [x] create_user(userJSON) - - [ ] delete_user(id) - - [x] deactivate_user(id) -- [x] merge user accounts - - [x] merge_users(dest_acct, source_acct) -- [x] change user identifier - - [x] change_user_identifier(old_identifier, new_identifier) -- [x] .../superuser/$identifier - - [x] superuser_toggle(userId) -- [x] GET /api/users/$USERNAME/traces - - [x] show_user_traces(username) -- [x] POST /api/users/$USERNAME/removeRoles - - [x] remove_all_roles(username) -- [x] .../assignments/assignees/$identifier - - [x] list_role_assignments(identifier) -- [x] .../permissions/$identifier - - [x] list_permissions(identifier) -- [x] .../assignee/$identifier - - [x] show_role_assignee(identifier) -- [ ] .../savedsearches - - [ ] list_searches() - - [ ] list_search(id) - - [ ] execute_search(id) -- [ ] .../datasets/integrity - - [ ] calculate_unf(datasetVerId) -- [ ] .../computeDataFileHashValue - - [ ] calculate_datafile_checksum(fileId) - - [ ] validate_current_datafile_checksum(fileId) -- [ ] .../validate/dataset/files/{datasetId} - - [ ] validate_dataset_files(datasetId) -- [ ] .../updateHashValues(algorithm, batch_size) - - [ ] update_dataset_hashes(datasetId) -- [ ] .../workflows - - [ ] list_workflows() - - [ ] show_workflow(id) - - [ ] add_workflow(workflowJSON) - - [ ] delete_workflow(id) - - [ ] list_default_workflow() - - [ ] set_default_workflow(workflow_id, workflow_trigger) - - [ ] unset_default_workflow(trigger_type) - - [ ] set_workflow_allowed_ip(allowed_list) - - [ ] get_workflow_allowed_ip() - - [ ] restore_workflow_default_allowed_ip() -- [ ] .../clearMetricsCache - - [ ] clear_cached_metrics() - - [ ] clear_metric_cache(metric_db_name) -- [ ] .../dataverse/{dataverse alias}/addRoleAssignmentsToChildren - - [ ] inherit_role_assignments(datavserse) -- [ ] /api/licenses - - [ ] view_licenses_available() - - [ ] view_dataset_license(id) - - [ ] add_dataset_license(licenseJSON) - - [ ] set_dataset_license() - - [ ] delete_dataset_license(id) - - [ ] set_dataset_license_sort(id, sort_order) -- [ ] .../templates - - [ ] list_templates() - - [ ] list_templates(id) - - [ ] delete_template(id) -- [ ] .../requestSignedUrl - - [ ] request_signed_url(url, timeout, http_method, user) -- [ ] .../feedback - - [ ] send_feedback(feedbackJSON) -- [ ] .../mydata - - [ ] list_data(role_id, dv_object_type, published_states, per_page)