-
Notifications
You must be signed in to change notification settings - Fork 5
/
build_json.py
47 lines (37 loc) · 1.81 KB
/
build_json.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/python
import json
import requests
import os
# location depends on whether or not you're in a docker container
api_location = "http://localhost:8080"
#api_location = "http://host.docker.internal:8080"
base_path = api_location + "/api"
data_path = os.path.join(os.path.dirname(__file__), "../data/")
# Get department data
response = requests.get(base_path + "/central-programs")
with open(data_path + "central-programs.json","w+") as f:
json.dump(response.json(),f, indent=2)
# Get resource data for central programs
response = requests.get(base_path + "/central-programs/resources")
with open(data_path + "central-programs-resources.json","w+") as f:
json.dump(response.json(),f, indent=2)
# Get sankey data (no grouping)
response = requests.get(base_path + "/sankey")
with open(data_path + "sankey.json","w+") as f:
json.dump(response.json(),f, indent=2)
# Get sankey data (restricted / unrestricted grouping)
response = requests.get(base_path + "/sankey?groupBy=restricted")
with open(data_path + "sankey-restricted.json","w+") as f:
json.dump(response.json(),f, indent=2)
# Get sankey data for each central program (no grouping)
response = requests.get(base_path + "/central-programs/sankey")
with open(data_path + "central-programs-sankey.json","w+") as f:
json.dump(response.json(),f, indent=2)
# Get sankey data for each central program (restricted / unrestricted grouping)
response = requests.get(base_path + "/central-programs/sankey?groupBy=restricted")
with open(data_path + "central-programs-sankey-restricted.json","w+") as f:
json.dump(response.json(),f, indent=2)
# Get overview data for central programs and all of OUSD
response = requests.get(base_path + "/central-programs/overview")
with open(data_path + "central-programs-overview.json","w+") as f:
json.dump(response.json(),f, indent=2)