-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPDAPInterface.py
49 lines (41 loc) · 1.17 KB
/
PDAPInterface.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
48
49
import json
from datetime import datetime
import requests
from enums import UpdateFrequency
class PDAPInterface:
def __init__(self, base_url: str):
self.base_url = base_url
def update_pdap_archives(
self,
entry: dict,
authorization_header: dict
):
"""
Update data in PDAP archives
:param entry:
:return:
"""
response = requests.put(
f"{self.base_url}/archives",
json=entry,
headers=authorization_header,
timeout=10
)
response.raise_for_status()
def get_from_pdap_archives(
self,
authorization_header: dict,
update_frequency: UpdateFrequency,
last_archived_before: datetime
):
response = requests.get(
f"{self.base_url}/archives",
params={
"update_frequency": update_frequency.value,
"last_archived_before": last_archived_before.strftime("%Y-%m-%d")
},
headers=authorization_header,
timeout=10
)
response.raise_for_status()
return response.json()