This repository has been archived by the owner on Apr 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
routes.py
101 lines (86 loc) · 2.98 KB
/
routes.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
from functools import wraps
from core.app_server import (
HeartbeatController,
returns_problem_detail,
)
from core.opds import VerboseAnnotator
from core.util.problem_detail import ProblemDetail
from app import app
def accepts_auth(f):
@wraps(f)
def decorated(*args, **kwargs):
client = app.wrangler.authenticated_client_from_request(
_db=app._db, required=False
)
if isinstance(client, ProblemDetail):
return client.response
return f(*args, **kwargs)
return decorated
def requires_auth(f):
@wraps(f)
def decorated(*args, **kwargs):
client = app.wrangler.authenticated_client_from_request(
app._db, required=True
)
if isinstance(client, ProblemDetail):
return client.response
return f(*args, **kwargs)
return decorated
@app.route('/', strict_slashes=False)
def index():
return app.wrangler.index.opds_catalog()
@app.route('/heartbeat')
def heartbeat():
return app.wrangler.heartbeat.heartbeat()
@app.route('/canonical-author-name')
@returns_problem_detail
def canonical_author_name():
return app.wrangler.canonicalization.canonicalize_author_name()
@app.route('/lookup')
@app.route('/<collection_metadata_identifier>/lookup')
@accepts_auth
@returns_problem_detail
def lookup(collection_metadata_identifier=None):
return app.wrangler.urn_lookup.work_lookup(
VerboseAnnotator, require_active_licensepool=False,
metadata_identifier=collection_metadata_identifier
)
@app.route('/<collection_metadata_identifier>/add', methods=['POST'])
@requires_auth
@returns_problem_detail
def add(collection_metadata_identifier):
return app.wrangler.catalog.add_items(
metadata_identifier=collection_metadata_identifier
)
@app.route('/<collection_metadata_identifier>/add_with_metadata', methods=['POST'])
@requires_auth
@returns_problem_detail
def add_with_metadata(collection_metadata_identifier):
return app.wrangler.catalog.add_with_metadata(
metadata_identifier=collection_metadata_identifier
)
@app.route('/<collection_metadata_identifier>/metadata_needed', methods=['GET'])
@requires_auth
@returns_problem_detail
def metadata_needed_for(collection_metadata_identifier):
return app.wrangler.catalog.metadata_needed_for(
metadata_identifier=collection_metadata_identifier
)
@app.route('/<collection_metadata_identifier>/updates')
@requires_auth
@returns_problem_detail
def updates(collection_metadata_identifier):
return app.wrangler.catalog.updates_feed(
metadata_identifier=collection_metadata_identifier
)
@app.route('/<collection_metadata_identifier>/remove', methods=['POST'])
@requires_auth
@returns_problem_detail
def remove(collection_metadata_identifier):
return app.wrangler.catalog.remove_items(
metadata_identifier=collection_metadata_identifier
)
@app.route("/register", methods=["POST"])
@returns_problem_detail
def register():
return app.wrangler.integration.register()