forked from uncch-rdmc/dataverse-toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweekly_report.py
More file actions
28 lines (22 loc) · 825 Bytes
/
weekly_report.py
File metadata and controls
28 lines (22 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python3
import argparse
import json
import requests
import ssl
# default to dataverse-awstest.irss.unc.edu
parser = argparse.ArgumentParser(description='Pull desired metrics from Dataverse API')
parser.add_argument('-d', '--dataverse', default='https://dataverse-awstest.irss.unc.edu', help='Dataverse URL. Defaults to https://dataverse-awstest.irss.unc.edu')
args = parser.parse_args()
api_prefix = "/api/info/metrics/"
metrics = ['dataverses','datasets','files','downloads']
# function to call each aggregate API endpoint
def call_api(metric):
url = args.dataverse + api_prefix + metric
r = requests.get(url)
j = r.json()
result = j["data"]["count"]
return result
# fire at will
for metric in metrics:
result = call_api(metric)
print("Total " + metric + ": " + str(result))