This repository has been archived by the owner on Sep 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wrapperInterface.py
87 lines (71 loc) · 2.29 KB
/
wrapperInterface.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env python3
import abc
from typing import Union
def error(name):
raise NotImplementedError(f"{name} must be defined to use this base class")
class WrapperInterface(metaclass=abc.ABCMeta):
@abc.abstractmethod
def __init__(self, apiKey: str):
error("__init__")
# Endpoint used for the query
@property
@abc.abstractmethod
def endpoint(self) -> str:
error("endpoint")
# A dictionary that contains the available result formats for each collection
@property
@abc.abstractmethod
def allowedResultFormats(self) -> {str: [str]}:
error("allowedResultFormats")
# The result format that will be used for the query
@property
@abc.abstractmethod
def resultFormat(self) -> str:
error("resultFormat")
# resultFormat must be settable
@resultFormat.setter
@abc.abstractmethod
def resultFormat(self, value: str):
error("resultFormat (setter)")
# Collection being used for the query
@property
@abc.abstractmethod
def collection(self) -> str:
error("collection")
# collection must be settable
@collection.setter
@abc.abstractmethod
def collection(self, value: str):
error("collection (setter)")
# Maximum number of results that the API will return
@property
@abc.abstractmethod
def maxRecords(self) -> int:
error("maxRecords")
# Dictionary of allowed keys and their allowed values for searchField()
@property
@abc.abstractmethod
def allowedSearchFields(self) -> {str: [str]}:
error("allowedSearchFields")
# Specify value for a given search parameter for manual search
@abc.abstractmethod
def searchField(self, key: str, value):
error("searchField")
# Reset a search parameter
@abc.abstractmethod
def resetField(self, key: str):
error("resetField")
# Translate a search in the wrapper input format into a query that the wrapper api understands
@abc.abstractmethod
def translateQuery(self, query: dict) -> str:
error("translateQuery")
# Set the index from which the returned results start
# (Necessary if there are more hits for a query than the maximum number of returned results.)
@abc.abstractmethod
def startAt(self, value: int):
error("startAt")
# Make the call to the API
# If no query is given, use the manual search specified by searchField() calls
@abc.abstractmethod
def callAPI(self, query: Union[dict, None], raw: bool, dry: bool):
error("callAPI")