Skip to content

Commit

Permalink
new file: destroy_all_dvobjects.py
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Jun 25, 2019
1 parent 4c85a6a commit 0630d67
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions destroy_all_dvobjects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from pyDataverse.api import Api
import json
import dvconfig
base_url = dvconfig.base_url
api_token = dvconfig.api_token
api = Api(base_url, api_token)
print(api.status)
#FIXME: remove hard coded dataverse alias
alias = 'open-source-at-harvard'
query_str = '/dataverses/' + alias + '/contents'
params = {}
params['foo'] = 'bar'
resp = api.get_request(query_str, params=params, auth=True)
print(json.dumps(resp.json(), indent=2))
# FIXME: iterate through all content instead of just looking at index 0.
protocol = resp.json()['data'][0]['protocol']
authority = resp.json()['data'][0]['authority']
identifier = resp.json()['data'][0]['identifier']
dataset_pid = protocol + ':' + authority + '/' + identifier
print(dataset_pid)
resp = api.delete_dataset(dataset_pid)
print(resp)
resp = api.delete_dataverse(alias)
print(resp)

0 comments on commit 0630d67

Please sign in to comment.