Skip to content

Add non-filtering endpoints #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ doc/examples/.bash_history
**/.bash_history

test_results/
src/jupyter/tmp
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- Added new endpoint 'csv' to return a query as a CSV text object.
- Added new `all_X` endpoints for indicators, categories, spatial, and temporal resolutions which return all of them even if no datasets exist that are accessible only with `admin` scope.


### Changed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a changelog entry for the upload nb changes?

Expand Down
65 changes: 65 additions & 0 deletions src/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,23 @@
}
}
},
"/all_categories": {
"get": {
"operationId": "list_all_categories",
"tags": ["data"],
"description":"Gets all available categories currently ingested in this flowkit-ui-backend instance",
"security": [{
"auth0": ["admin"]
}],
"responses": {
"200": { "$ref": "#/components/responses/categories" },
"401": { "$ref": "#/components/responses/unauthorized" },
"429": { "$ref": "#/components/responses/too_many_requests" },
"500": { "$ref": "#/components/responses/internal_server_error" },
"503": { "$ref": "#/components/responses/service_unavailable" }
}
}
},
"/categories/{category_id}": {
"parameters": [
{"$ref": "#/components/parameters/category_id"}
Expand Down Expand Up @@ -347,6 +364,22 @@
}
}
},
"/all_indicators": {
"get": {
"operationId": "list_all_indicators",
"tags": ["data"],
"description":"Gets all available indicators currently ingested in this flowkit-ui-backend instance",
"security": [{
"auth0": ["admin"]
}],
"responses": {
"200": { "$ref": "#/components/responses/indicators" },
"401": { "$ref": "#/components/responses/unauthorized" },
"429": { "$ref": "#/components/responses/too_many_requests" },
"500": { "$ref": "#/components/responses/internal_server_error" },
"503": { "$ref": "#/components/responses/service_unavailable" }
}
}},
"/indicators/{indicator_id}": {
"parameters": [
{"$ref": "#/components/parameters/indicator_id"}
Expand Down Expand Up @@ -490,6 +523,22 @@
}
}
},
"/all_spatial_resolutions": {
"get": {
"operationId": "list_all_spatial_resolutions",
"tags": ["data"],
"description":"Gets all available spatial resolutions currently ingested in this flowkit-ui-backend instance. This excludes the boundaries, which are typically quite large and should be retrieved individually.",
"security": [{
"auth0": ["admin"]
}],
"responses": {
"200": { "$ref": "#/components/responses/spatial_resolutions" },
"401": { "$ref": "#/components/responses/unauthorized" },
"429": { "$ref": "#/components/responses/too_many_requests" },
"500": { "$ref": "#/components/responses/internal_server_error" },
"503": { "$ref": "#/components/responses/service_unavailable" }
}
}},
"/spatial_resolutions/{srid}": {
"parameters": [
{"$ref": "#/components/parameters/srid"}
Expand Down Expand Up @@ -642,6 +691,22 @@
}
}
},
"/all_temporal_resolutions": {
"get": {
"operationId": "list_all_temporal_resolutions",
"tags": ["data"],
"description":"Gets all available temporal resolutions currently ingested in this flowkit-ui-backend instance",
"security": [{
"auth0": ["admin"]
}],
"responses": {
"200": { "$ref": "#/components/responses/temporal_resolutions" },
"401": { "$ref": "#/components/responses/unauthorized" },
"429": { "$ref": "#/components/responses/too_many_requests" },
"500": { "$ref": "#/components/responses/internal_server_error" },
"503": { "$ref": "#/components/responses/service_unavailable" }
}
}},
"/temporal_resolutions/{trid}": {
"parameters": [
{"$ref": "#/components/parameters/trid"}
Expand Down
20 changes: 20 additions & 0 deletions src/impl/apis/data_api_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ async def list_categories(pool: Pool, token_model: TokenModel) -> Optional[Categ
return Categories(categories=categories)


async def list_all_categories(pool: Pool, token_model: TokenModel) -> Optional[Categories]:
return await list_categories(pool=pool, token_model=None)


async def get_category(category_id: str, pool: Pool, token_model: TokenModel) -> Category:
categories = await db.select_data(
base_model=Category,
Expand All @@ -63,6 +67,10 @@ async def list_indicators(pool: Pool, token_model: TokenModel) -> Optional[Indic
return Indicators(indicators=indicators)


async def list_all_indicators(pool: Pool, token_model: TokenModel) -> Optional[Indicators]:
return await list_indicators(pool=pool, token_model=None)


async def get_indicator(indicator_id: str, pool: Pool, token_model: TokenModel) -> Indicator:
indicators = await db.select_data(
base_model=Indicator,
Expand Down Expand Up @@ -101,6 +109,12 @@ async def list_spatial_resolutions(
return SpatialResolutions(spatial_resolutions=spatial_resolutions)


async def list_all_spatial_resolutions(
pool: Pool, token_model: TokenModel
) -> Optional[SpatialResolutions]:
return await list_spatial_resolutions(pool=pool, token_model=None)


async def get_spatial_resolution(
srid: int, pool: Pool, token_model: TokenModel
) -> SpatialResolution:
Expand Down Expand Up @@ -154,6 +168,12 @@ async def list_temporal_resolutions(
return TemporalResolutions(temporal_resolutions=temporal_resolutions)


async def list_all_temporal_resolutions(
pool: Pool, token_model: TokenModel
) -> Optional[TemporalResolutions]:
return await list_temporal_resolutions(pool=pool, token_model=None)


async def get_temporal_resolution(
trid: int, pool: Pool, token_model: TokenModel
) -> TemporalResolution:
Expand Down
Loading