Skip to content

Commit

Permalink
SFR-2412: Migrate collection endpoint to use plural noun (#483)
Browse files Browse the repository at this point in the history
* migrate collection endpoint

* fixing init

* update list endpoint to base

---------

Co-authored-by: kyle <[email protected]>
  • Loading branch information
jackiequach and kylevillegas93 authored Dec 19, 2024
1 parent b0170b9 commit f1ec3bc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from logger import create_log
from .blueprints import (
search, work, info, edition, editions, utils, link, opds, collection, citation, fulfill
search, work, info, edition, editions, utils, link, opds, collection, collections, citation, fulfill
)
from .utils import APIUtils

Expand All @@ -36,6 +36,7 @@ def __init__(self, dbEngine, redisClient):
self.app.register_blueprint(link)
self.app.register_blueprint(opds)
self.app.register_blueprint(collection)
self.app.register_blueprint(collections)
self.app.register_blueprint(citation)
self.app.register_blueprint(fulfill)

Expand Down
2 changes: 1 addition & 1 deletion api/blueprints/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .drbCitation import citation
from .drbCollection import collection
from .drbCollection import collection, collections
from .drbEdition import edition, editions
from .drbInfo import info
from .drbLink import link
Expand Down
8 changes: 8 additions & 0 deletions api/blueprints/drbCollection.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
logger = create_log(__name__)

collection = Blueprint('collection', __name__, url_prefix='/collection')
collections = Blueprint('collections', __name__, url_prefix='/collections')


def validateToken(func):
Expand Down Expand Up @@ -57,6 +58,7 @@ def decorator(*args, **kwargs):


@collection.route('', methods=['POST'])
@collections.route('', methods=['POST'])
@validateToken
def collectionCreate(user=None):
logger.info('Creating new collection')
Expand Down Expand Up @@ -139,6 +141,7 @@ def _validateAutoCollectionDef(autoDef: dict) -> str:


@collection.route('/replace/<uuid>', methods=['POST'])
@collections.route('/replace/<uuid>', methods=['POST'])
@validateToken
def collectionReplace(uuid, user=None):
logger.info('Handling collection replacement request')
Expand Down Expand Up @@ -190,6 +193,7 @@ def collectionReplace(uuid, user=None):
return APIUtils.formatOPDS2Object(201, opdsFeed)

@collection.route('/update/<uuid>', methods=['POST'])
@collections.route('/update/<uuid>', methods=['POST'])
@validateToken
def collectionUpdate(uuid, user=None):
logger.info('Handling collection update request')
Expand Down Expand Up @@ -259,6 +263,7 @@ def collectionUpdate(uuid, user=None):


@collection.route('/<uuid>', methods=['GET'])
@collections.route('/<uuid>', methods=['GET'])
def get_collection(uuid):
logger.info(f'Getting collection with id {uuid}')
response_type = 'fetchCollection'
Expand Down Expand Up @@ -291,6 +296,7 @@ def get_collection(uuid):
return APIUtils.formatResponseObject(500, response_type, { 'message': f'Unable to get collection with id {uuid}' })

@collection.route('/<uuid>', methods=['DELETE'])
@collections.route('/<uuid>', methods=['DELETE'])
@validateToken
def collectionDelete(uuid, user=None):
logger.info('Deleting collection {}'.format(uuid))
Expand All @@ -311,6 +317,7 @@ def collectionDelete(uuid, user=None):
return (jsonify({'message': 'Deleted {}'.format(uuid)}), 200)

@collection.route('/delete/<uuid>', methods=['DELETE'])
@collections.route('/delete/<uuid>', methods=['DELETE'])
@validateToken
def collectionDeleteWorkEdition(uuid, user=None):
logger.info('Handling collection work/edition deletion request')
Expand Down Expand Up @@ -355,6 +362,7 @@ def collectionDeleteWorkEdition(uuid, user=None):


@collection.route('/list', methods=['GET'])
@collections.route('', methods=['GET'])
def get_collections():
logger.info('Getting all collections')
response_type = 'collectionList'
Expand Down
12 changes: 6 additions & 6 deletions swagger.v4.json
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@
}
}
},
"/collection": {
"/collections": {
"post": {
"tags": ["digital-research-books"],
"summary": "Create DRB Collection",
Expand Down Expand Up @@ -699,7 +699,7 @@
}
}
},
"/collection/{uuid}": {
"/collections/{uuid}": {
"get": {
"tags": ["digital-research-books"],
"summary": "Return DRB Collection",
Expand Down Expand Up @@ -800,7 +800,7 @@
}
}
},
"/collection/replace/{uuid}": {
"/collections/replace/{uuid}": {
"post": {
"tags": ["digital-research-books"],
"summary": "Replace a DRB Collection",
Expand Down Expand Up @@ -880,7 +880,7 @@
}
}
},
"/collection/update/{uuid}": {
"/collections/update/{uuid}": {
"post": {
"tags": ["digital-research-books"],
"summary": "Update a DRB Collection",
Expand Down Expand Up @@ -962,7 +962,7 @@
}
}
},
"/collection/delete/{uuid}": {
"/collections/delete/{uuid}": {
"delete": {
"tags": ["digital-research-books"],
"summary": "Delete a Edition/Work from a DRB Collection",
Expand Down Expand Up @@ -1016,7 +1016,7 @@
}
}
},
"/collection/list": {
"/collections/list": {
"get": {
"tags": ["digital-research-books"],
"summary": "Return list of DRB Collections",
Expand Down

0 comments on commit f1ec3bc

Please sign in to comment.