Skip to content

Commit

Permalink
refactor(api): modify Search API endpoint URL paths #398
Browse files Browse the repository at this point in the history
The Search endpoint URL paths have been modified to follow the format
that the PaNOSC Federated Search API sets out. These changes were made:
- The Datasets endpoint URL was modified from /datasets to /Datasets
- The Documents endpoint URL was modified from /documents to /Documents
- The Instruments endpoint URL was modified from /instruments to
    /Instruments

BREAKING CHANGE: modify Search API endpoint URL paths
  • Loading branch information
VKTB committed Feb 14, 2023
1 parent 4ac95b6 commit 1dc815b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
14 changes: 7 additions & 7 deletions datagateway_api/src/api_start_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ def create_api_endpoints(flask_app, api, specs):
)
search_api_extension = Config.config.search_api.extension
search_api_entity_endpoints = {
"datasets": "Dataset",
"documents": "Document",
"instruments": "Instrument",
"Datasets": "Dataset",
"Documents": "Document",
"Instruments": "Instrument",
}

for endpoint_name, entity_name in search_api_entity_endpoints.items():
Expand Down Expand Up @@ -320,8 +320,8 @@ def create_api_endpoints(flask_app, api, specs):
get_files_endpoint_resource = get_files_endpoint("File")
api.add_resource(
get_files_endpoint_resource,
f"{search_api_extension}/datasets/<string:pid>/files",
endpoint="search_api_get_dataset_files",
f"{search_api_extension}/Datasets/<string:pid>/files",
endpoint="search_api_get_Dataset_files",
)
search_api_spec.path(resource=get_files_endpoint_resource, api=api)

Expand All @@ -330,8 +330,8 @@ def create_api_endpoints(flask_app, api, specs):
)
api.add_resource(
get_number_count_files_endpoint_resource,
f"{search_api_extension}/datasets/<string:pid>/files/count",
endpoint="search_api_count_dataset_files",
f"{search_api_extension}/Datasets/<string:pid>/files/count",
endpoint="search_api_count_Dataset_files",
)
search_api_spec.path(resource=get_number_count_files_endpoint_resource, api=api)

Expand Down
10 changes: 5 additions & 5 deletions datagateway_api/src/resources/search_api_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_search_endpoint(entity_name):
"""
Given an entity name, generate a flask_restful `Resource` class. In
`create_api_endpoints()`, these generated classes are registered with the API e.g.
`api.add_resource(get_search_endpoint("Dataset"), "/datasets")`
`api.add_resource(get_search_endpoint("Dataset"), "/Datasets")`
:param entity_name: Name of the entity
:type entity_name: :class:`str`
Expand Down Expand Up @@ -80,7 +80,7 @@ def get_single_endpoint(entity_name):
"""
Given an entity name, generate a flask_restful `Resource` class. In
`create_api_endpoints()`, these generated classes are registered with the API e.g.
`api.add_resource(get_single_endpoint("Dataset"), "/datasets/<string:pid>")`
`api.add_resource(get_single_endpoint("Dataset"), "/Datasets/<string:pid>")`
:param entity_name: Name of the entity
:type entity_name: :class:`str`
Expand Down Expand Up @@ -130,7 +130,7 @@ def get_number_count_endpoint(entity_name):
"""
Given an entity name, generate a flask_restful `Resource` class. In
`create_api_endpoints()`, these generated classes are registered with the API e.g.
`api.add_resource(get_number_count_endpoint("Dataset"), "/datasets/count")`
`api.add_resource(get_number_count_endpoint("Dataset"), "/Datasets/count")`
:param entity_name: Name of the entity
:type entity_name: :class:`str`
Expand Down Expand Up @@ -175,7 +175,7 @@ def get_files_endpoint(entity_name):
"""
Given an entity name, generate a flask_restful `Resource` class. In
`create_api_endpoints()`, these generated classes are registered with the API e.g.
`api.add_resource(get_files_endpoint("Dataset"), "/datasets/<string:pid>/files")`
`api.add_resource(get_files_endpoint("Dataset"), "/Datasets/<string:pid>/files")`
:param entity_name: Name of the entity
:type entity_name: :class:`str`
Expand Down Expand Up @@ -231,7 +231,7 @@ def get_number_count_files_endpoint(entity_name):
Given an entity name, generate a flask_restful `Resource` class. In
`create_api_endpoints()`, these generated classes are registered with the API e.g.
`api.add_resource(get_number_count_files_endpoint("Dataset"),
"/datasets<string:pid>/files/count")`
"/Datasets<string:pid>/files/count")`
:param entity_name: Name of the entity
:type entity_name: :class:`str`
Expand Down
22 changes: 11 additions & 11 deletions datagateway_api/src/swagger/search_api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ info:
version: '1.0'
openapi: 3.0.3
paths:
/search-api/datasets:
/search-api/Datasets:
get:
description: Retrieves a list of Dataset objects
parameters:
Expand All @@ -490,7 +490,7 @@ paths:
summary: Get Datasets
tags:
- Dataset
/search-api/datasets/{pid}:
/search-api/Datasets/{pid}:
get:
description: Retrieves a Dataset object with the matching pid
parameters:
Expand All @@ -516,7 +516,7 @@ paths:
summary: Find the Dataset matching the given pid
tags:
- Dataset
/search-api/datasets/count:
/search-api/Datasets/count:
get:
description: Return the count of the Dataset objects that would be retrieved
given the filters provided
Expand All @@ -536,7 +536,7 @@ paths:
summary: Count Datasets
tags:
- Dataset
/search-api/documents:
/search-api/Documents:
get:
description: Retrieves a list of Document objects
parameters:
Expand All @@ -557,7 +557,7 @@ paths:
summary: Get Documents
tags:
- Document
/search-api/documents/{pid}:
/search-api/Documents/{pid}:
get:
description: Retrieves a Document object with the matching pid
parameters:
Expand All @@ -583,7 +583,7 @@ paths:
summary: Find the Document matching the given pid
tags:
- Document
/search-api/documents/count:
/search-api/Documents/count:
get:
description: Return the count of the Document objects that would be retrieved
given the filters provided
Expand All @@ -603,7 +603,7 @@ paths:
summary: Count Documents
tags:
- Document
/search-api/instruments:
/search-api/Instruments:
get:
description: Retrieves a list of Instrument objects
parameters:
Expand All @@ -624,7 +624,7 @@ paths:
summary: Get Instruments
tags:
- Instrument
/search-api/instruments/{pid}:
/search-api/Instruments/{pid}:
get:
description: Retrieves a Instrument object with the matching pid
parameters:
Expand All @@ -650,7 +650,7 @@ paths:
summary: Find the Instrument matching the given pid
tags:
- Instrument
/search-api/instruments/count:
/search-api/Instruments/count:
get:
description: Return the count of the Instrument objects that would be retrieved
given the filters provided
Expand All @@ -670,7 +670,7 @@ paths:
summary: Count Instruments
tags:
- Instrument
/search-api/datasets/{pid}/files:
/search-api/Datasets/{pid}/files:
get:
description: Retrieves a list of File objects for a given Dataset object
parameters:
Expand Down Expand Up @@ -699,7 +699,7 @@ paths:
summary: Get Files for the given Dataset
tags:
- Dataset
/search-api/datasets/{pid}/files/count:
/search-api/Datasets/{pid}/files/count:
get:
description: Return the count of File objects for the given Dataset object that
would be retrieved given the filters provided
Expand Down

0 comments on commit 1dc815b

Please sign in to comment.