Skip to content
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

Remove deprecated rest endpoints, parameters and keys #1037

Merged
merged 7 commits into from
Jan 8, 2025
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
- [#1009](https://github.com/LayerManager/layman/issues/1009) Fill column `description` in `publications` table in prime DB schema. Value is taken from GeoServer for layers and from filesystem for maps.
### Changes
- [#1009](https://github.com/LayerManager/layman/issues/1009) PATCH Workspace [Layer](doc/rest.md#patch-workspace-layer)/[Map](doc/rest.md#patch-workspace-map) returns same response as POST Workspace [Layers](doc/rest.md#post-workspace-layers)/[Maps](doc/rest.md#post-workspace-maps) with only `name`, `uuid`, `url` and for Layer also optional `files_to_upload` keys.
- [#1009](https://github.com/LayerManager/layman/issues/1009) Deprecated endpoint, parameters and keys were removed:
- key `file_type` was removed from endpoints GET [Publications](doc/rest.md#get-publications)/[Layers](doc/rest.md#get-layers)/[Workspace Layers](doc/rest.md#get-workspace-layers)/[Workspace Layer](doc/rest.md#get-workspace-layer) response
- key `file`.`path` was removed from GET [Workspace Layer](doc/rest.md#get-workspace-layer) response
- key `sld` was removed from GET [Workspace Layer](doc/rest.md#get-workspace-layer) response
- key `db_table` was removed from GET [Workspace Layer](doc/rest.md#get-workspace-layer) response
- key `data`.`layman`.`last-migration` was removed from [GET Version](doc/rest.md#get-version) response
- body parameter `sld` was removed from [POST Workspace Publications](doc/rest.md#post-workspace-layers) and [PATCH Workspace Publication](doc/rest.md#patch-workspace-layer)
- workspace-related endpoints which did not include `/workspaces` in their path were removed
- [#1028](https://github.com/LayerManager/layman/issues/1028) Upgrade Node.js of Laymen Test Client from v18 to v22 and dependencies:
- eslint-config-next 13 -> 14
- next 13 -> 14
Expand Down
27 changes: 0 additions & 27 deletions doc/rest.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
- **workspace_name**, string `^[a-z][a-z0-9]*(_[a-z0-9]+)*$`
- string identifying [workspace](models.md#workspace)

**_NOTE:_** Before version 1.10.0, workspace-related endpoints did not include `/workspaces` in their path. These old endpoints are still functional, but deprecated. More specifically, they return HTTP header **Deprecation**. If you get such header in response, rewrite your client to use new endpoint path. Old endpoints will stop working in the next major release.

## Publications
### URL
`/rest/publications`
Expand Down Expand Up @@ -72,8 +70,6 @@ JSON array of objects representing available layers and maps with following stru
- **native_crs**: Code of native CRS in form "EPSG:<code>", e.g. "EPSG:4326".
- **native_bounding_box**: List of 4 floats and one string. Bounding box coordinates [minx, miny, maxx, maxy] in native CRS.
- *geodata_type*: String. Available only for layers. Either `vector`, `raster`, or `unknown`. Value `unknown` is used if input files are zipped and still being uploaded.
- *~~file~~*: **Deprecated**.
- *~~file_type~~*: **Deprecated**. Replaced by **geodata_type** at root level, contains same info. Available only for layers.
- *wfs_wms_status*: String. Available only for layers. Status of layer availability in WMS (and WFS in case of vector data) endpoints. Either `AVAILABLE`, `PREPARING`, or `NOT_AVAILABLE`.

Headers:
Expand Down Expand Up @@ -206,9 +202,6 @@ Body parameters:
- *access_rights.write*, string
- comma-separated names of [users](./models.md#user) and [roles](./models.md#role) who will get [write access](./security.md#publication-access-rights) to this publication
- default value is current authenticated user, or EVERYONE if published by anonymous
- ~~sld~~, SLD file
- **deprecated parameter**
- alias for *style* parameter
- *overview_resampling*, string
- supported only for raster layers
- method used by [`gdaladdo`](https://gdal.org/en/stable/programs/gdaladdo.html#cmdoption-gdaladdo-r) for overview resampling when normalizing raster layer
Expand Down Expand Up @@ -310,12 +303,6 @@ JSON object with following structure:
- **file**
- *paths*: List of strings. Paths to all main input data files. Path is relative to workspace directory.
If data file was sent in ZIP archive to the server, path includes also path to the main file inside ZIP file. E.g. `layers/zipped_shapefile/input_file/zipped_shapefile.zip/layer_main_file.shp`
- *~~path~~*:
- **Deprecated**
- Replaced by *paths*, which contains list of all data files.
- String. Path to input data file. Path is relative to workspace directory.
If data file was sent in ZIP archive to the server, path includes also path to the main file inside ZIP file. E.g. `layers/zipped_shapefile/input_file/zipped_shapefile.zip/layer_main_file.shp`
- *~~file_type~~*: **Deprecated**. Replaced by **geodata_type** at root level, contains same info.
- *status*: Status information about saving and availability of files. See [GET Workspace Layer](#get-workspace-layer) **wms** property for meaning.
- *error*: If status is FAILURE, this may contain error object.
- *db*, available only for vector layers
Expand All @@ -325,19 +312,11 @@ JSON object with following structure:
- *external_uri*: String. Available only for layers published from external table. Connection string to external table without password.
- *status*: Status information about DB import and availability of the table. See [GET Workspace Layer](#get-workspace-layer) **wms** property for meaning.
- *error*: If status is FAILURE, this may contain error object.
- *~~db_table~~*: **Deprecated**. Replaced by **db**.
- available only for vector layers
- *~~name~~*: Replaced by db.table.
- *~~status~~*: Replaced by db.status.
- *~~error~~*: Replaced by db.error.
- **style**
- *url*: String. URL of layer default style. It points to [GET Workspace Layer Style](#get-workspace-layer-style).
- *type*: String. Type of used style. Either 'sld' or 'qml'.
- *status*: Status information about publishing style. See [GET Workspace Layer](#get-workspace-layer) **wms** property for meaning.
- *error*: If status is FAILURE, this may contain error object.
- **~~sld~~**
- **Deprecated**
- Replaced by **style**, contains same info
- **original_data_source**: String. Either `file` if layer was published from file, or `database_table` if layer was published from external database table
- *metadata*
- *identifier*: String. Identifier of metadata record in CSW instance.
Expand Down Expand Up @@ -410,9 +389,6 @@ Body parameters:
- comma-separated names of [users](./models.md#user) and [roles](./models.md#role) who will get [read access](./security.md#publication-access-rights) to this publication
- *access_rights.write*, string
- comma-separated names of [users](./models.md#user) and [roles](./models.md#role) who will get [write access](./security.md#publication-access-rights) to this publication
- ~~sld~~, SLD file
- **deprecated parameter**
- alias for *style* parameter
- *overview_resampling*, string
- supported only for raster layers
- method used by [`gdaladdo`](https://gdal.org/en/stable/programs/gdaladdo.html#cmdoption-gdaladdo-r) for overview resampling when normalizing raster layer
Expand Down Expand Up @@ -889,6 +865,3 @@ JSON object representing current application version:
- **layman**:
- **last-schema-migration**: String. Identifier of the last successful schema migration in format 'X.Y.Z-m'.
- **last-data-migration**: String. Identifier of the last successful data migration in format 'X.Y.Z-m'.
- **~~last-migration~~**:
- **deprecated parameter**
- alias for *last-schema-migration* parameter
1 change: 0 additions & 1 deletion src/layman/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

for bp in get_workspace_blueprints():
app.register_blueprint(bp, url_prefix=f'/rest/{settings.REST_WORKSPACES_PREFIX}/<workspace>')
app.register_blueprint(bp, url_prefix='/rest/<workspace>', name=bp.name + '_deprecated')

for bp in get_blueprints():
app.register_blueprint(bp, url_prefix=f'/rest')
Expand Down
3 changes: 0 additions & 3 deletions src/layman/common/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,6 @@ def get_publications(publication_type, actor, request_args=None, workspace=None,
'native_crs': info['native_crs'],
'native_bounding_box': info['native_bounding_box'],
'geodata_type': info['geodata_type'],
'file': {
'file_type': info['geodata_type'],
},
'wfs_wms_status': info['_wfs_wms_status'].value if info['_wfs_wms_status'] else None,
}
multi_info_keys_to_remove = layman_util.get_multi_info_keys_to_remove(info['type'])
Expand Down
10 changes: 5 additions & 5 deletions src/layman/layer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,22 @@ def get_layer_patch_keys():
'info_keys': {
(settings.GEODATA_TYPE_VECTOR, settings.EnumOriginalDataSource.FILE.value): {
'name', 'uuid', 'layman_metadata', 'url', 'title', 'description', 'updated_at', 'wms', 'wfs', 'thumbnail', 'file',
'db', 'metadata', 'style', 'sld', 'access_rights', 'bounding_box', 'native_crs', 'native_bounding_box',
'original_data_source', 'geodata_type', 'db_table',
'db', 'metadata', 'style', 'access_rights', 'bounding_box', 'native_crs', 'native_bounding_box',
'original_data_source', 'geodata_type',
},
(settings.GEODATA_TYPE_VECTOR, settings.EnumOriginalDataSource.TABLE.value): {
'name', 'uuid', 'layman_metadata', 'url', 'title', 'description', 'updated_at', 'wms', 'wfs', 'thumbnail',
'db', 'metadata', 'style', 'sld', 'access_rights', 'bounding_box', 'native_crs', 'native_bounding_box',
'db', 'metadata', 'style', 'access_rights', 'bounding_box', 'native_crs', 'native_bounding_box',
'original_data_source', 'geodata_type',
},
settings.GEODATA_TYPE_RASTER: {
'name', 'uuid', 'layman_metadata', 'url', 'title', 'description', 'updated_at', 'wms', 'thumbnail', 'file', 'metadata',
'style', 'sld', 'access_rights', 'bounding_box', 'native_crs', 'native_bounding_box', 'image_mosaic',
'style', 'access_rights', 'bounding_box', 'native_crs', 'native_bounding_box', 'image_mosaic',
'original_data_source', 'geodata_type',
},
settings.GEODATA_TYPE_UNKNOWN: {
'name', 'uuid', 'layman_metadata', 'url', 'title', 'description', 'updated_at', 'wms', 'thumbnail', 'file', 'metadata',
'style', 'sld', 'access_rights', 'bounding_box', 'native_crs', 'native_bounding_box', 'original_data_source', 'geodata_type',
'style', 'access_rights', 'bounding_box', 'native_crs', 'native_bounding_box', 'original_data_source', 'geodata_type',
},
},
'multi_info_keys_to_remove': [],
Expand Down
1 change: 0 additions & 1 deletion src/layman/layer/filesystem/input_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def get_layer_info(workspace, layername):
file_type = get_file_type(rel_main_filepath)
result = {
'file': {
'path': rel_main_filepath,
'paths': [os.path.relpath(filepath, common_util.get_workspace_dir(workspace)) for filepath in main_files],
},
'_file': {
Expand Down
8 changes: 0 additions & 8 deletions src/layman/layer/rest_workspace_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ def before_request():
pass


@bp.after_request
def after_request(response):
layman_util.check_deprecated_url(response)
return response


@bp.route(f"/{LAYER_REST_PATH_NAME}/<layername>", methods=['GET'])
def get(workspace, layername):
# pylint: disable=unused-argument
Expand Down Expand Up @@ -117,8 +111,6 @@ def patch(workspace, layername):
style_file = None
if 'style' in request.files and not request.files['style'].filename == '':
style_file = request.files['style']
elif 'sld' in request.files and not request.files['sld'].filename == '':
style_file = request.files['sld']

delete_from = None
style_type = None
Expand Down
8 changes: 1 addition & 7 deletions src/layman/layer/rest_workspace_layer_chunk.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from flask import Blueprint, jsonify, request, current_app as app, g

from layman import LaymanError, util as layman_util
from layman import LaymanError
from layman.util import check_workspace_name_decorator
from layman.authn import authenticate
from layman.authz import authorize_workspace_publications_decorator
Expand All @@ -19,12 +19,6 @@ def before_request():
pass


@bp.after_request
def after_request(response):
layman_util.check_deprecated_url(response)
return response


@bp.route(f"/{LAYER_REST_PATH_NAME}/<layername>/chunk", methods=['POST'])
def post(workspace, layername):
app.logger.info(f"POST Layer Chunk, actor={g.user}")
Expand Down
6 changes: 0 additions & 6 deletions src/layman/layer/rest_workspace_layer_metadata_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ def before_request():
pass


@bp.after_request
def after_request(response):
layman_util.check_deprecated_url(response)
return response


@bp.route(f"/{LAYER_REST_PATH_NAME}/<layername>/metadata-comparison", methods=['GET'])
def get(workspace, layername):
app.logger.info(f"GET Layer Metadata Comparison, actor={g.user}")
Expand Down
6 changes: 0 additions & 6 deletions src/layman/layer/rest_workspace_layer_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ def before_request():
pass


@bp.after_request
def after_request(response):
layman_util.check_deprecated_url(response)
return response


@bp.route(f"/{LAYER_REST_PATH_NAME}/<layername>/style", methods=['GET'])
def get(workspace, layername):
app.logger.info(f"GET Style, actor={g.user}, workspace={workspace}, layername={layername}")
Expand Down
8 changes: 1 addition & 7 deletions src/layman/layer/rest_workspace_layer_thumbnail.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from flask import Blueprint, send_file, current_app as app, g

from layman.common.filesystem.util import get_workspace_dir
from layman import LaymanError, util as layman_util
from layman import LaymanError
from layman.util import check_workspace_name_decorator
from layman.authn import authenticate
from layman.authz import authorize_workspace_publications_decorator
Expand All @@ -22,12 +22,6 @@ def before_request():
pass


@bp.after_request
def after_request(response):
layman_util.check_deprecated_url(response)
return response


@bp.route(f"/{LAYER_REST_PATH_NAME}/<layername>/thumbnail", methods=['GET'])
def get(workspace, layername):
app.logger.info(f"GET Layer Thumbnail, actor={g.user}")
Expand Down
8 changes: 0 additions & 8 deletions src/layman/layer/rest_workspace_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ def before_request():
pass


@bp.after_request
def after_request(response):
layman_util.check_deprecated_url(response)
return response


@bp.route(f"/{LAYER_REST_PATH_NAME}", methods=['GET'])
def get(workspace):
app.logger.info(f"GET Layers, actor={g.user}")
Expand Down Expand Up @@ -151,8 +145,6 @@ def post(workspace):
style_file = None
if 'style' in request.files and not request.files['style'].filename == '':
style_file = request.files['style']
elif 'sld' in request.files and not request.files['sld'].filename == '':
style_file = request.files['sld']
style_type = input_style.get_style_type_from_file_storage(style_file)

if geodata_type == settings.GEODATA_TYPE_RASTER and style_type.code == 'qml':
Expand Down
7 changes: 0 additions & 7 deletions src/layman/layer/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,11 @@ def _get_complete_layer_info(workspace, layername, *, x_forwarded_items=None):
'title': layername,
'description': '',
})
if original_data_source == settings.EnumOriginalDataSource.FILE.value and partial_info.get('db', {}).get('table') is not None:
partial_info['db_table'] = {
'name': partial_info['db']['table'],
}

complete_info.update(partial_info)
complete_info['sld'] = complete_info['style']
file_type = complete_info.get('_file', {}).get('file_type')
if complete_info['geodata_type'] == settings.GEODATA_TYPE_UNKNOWN and file_type and file_type != settings.GEODATA_TYPE_UNKNOWN:
complete_info['geodata_type'] = file_type
if 'file' in complete_info:
complete_info['file']['file_type'] = complete_info['geodata_type']

complete_info = clear_publication_info(complete_info, geodata_type)

Expand Down
4 changes: 2 additions & 2 deletions src/layman/layer/util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def successful():
'native_crs': 'EPSG:3857',
'native_bounding_box': [1870322.81512642, 6281928.49798181, 1892002.82941466, 6304200.72172059],
'access_rights': {'read': ['lay3', 'EVERYONE'], 'write': ['lay3', 'EVERYONE']},
'file': {'path': 'layers/name_of_layer/input_file/name_of_layer.geojson', },
'file': {'paths': ['layers/name_of_layer/input_file/name_of_layer.geojson'], },
'_file': {'file_type': settings.GEODATA_TYPE_VECTOR},
'geodata_type': settings.GEODATA_TYPE_UNKNOWN,
'db': {'table': 'layer_157d0c0b-f893-4b93-bd2f-04a771822e09'},
Expand Down Expand Up @@ -142,7 +142,7 @@ def successful():
]
},
'file': {
'path': 'layers/name_of_layer/input_file/name_of_layer.geojson',
'paths': ['layers/name_of_layer/input_file/name_of_layer.geojson'],
},
'_file': {
'file_type': 'vector'
Expand Down
2 changes: 1 addition & 1 deletion src/layman/map/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def get_map_patch_keys():
},
'info_keys': {'name', 'uuid', 'layman_metadata', 'url', 'title', 'description', 'updated_at',
'thumbnail', 'file', 'metadata', 'access_rights', 'bounding_box', },
'multi_info_keys_to_remove': ['file', 'geodata_type', 'wfs_wms_status', ],
'multi_info_keys_to_remove': ['geodata_type', 'wfs_wms_status', ],
'patch_keys': ['name', 'uuid', 'url'],
}
}
Expand Down
6 changes: 0 additions & 6 deletions src/layman/map/rest_workspace_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ def before_request():
pass


@bp.after_request
def after_request(response):
layman_util.check_deprecated_url(response)
return response


@bp.route(f"/{MAP_REST_PATH_NAME}/<mapname>", methods=['GET'])
def get(workspace, mapname):
# pylint: disable=unused-argument
Expand Down
6 changes: 0 additions & 6 deletions src/layman/map/rest_workspace_map_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ def before_request():
pass


@bp.after_request
def after_request(response):
layman_util.check_deprecated_url(response)
return response


@bp.route(f"/{MAP_REST_PATH_NAME}/<mapname>/file", methods=['GET'])
def get(workspace, mapname):
app.logger.info(f"GET Map File, actor={g.user}")
Expand Down
6 changes: 0 additions & 6 deletions src/layman/map/rest_workspace_map_metadata_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ def before_request():
pass


@bp.after_request
def after_request(response):
layman_util.check_deprecated_url(response)
return response


@bp.route(f"/{MAP_REST_PATH_NAME}/<mapname>/metadata-comparison", methods=['GET'])
def get(workspace, mapname):
app.logger.info(f"GET Map Metadata Comparison, actor={g.user}")
Expand Down
8 changes: 1 addition & 7 deletions src/layman/map/rest_workspace_map_thumbnail.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from flask import Blueprint, send_file, current_app as app, g

from layman import LaymanError, util as layman_util
from layman import LaymanError
from layman.util import check_workspace_name_decorator
from layman.authn import authenticate
from layman.authz import authorize_workspace_publications_decorator
Expand All @@ -21,12 +21,6 @@ def before_request():
pass


@bp.after_request
def after_request(response):
layman_util.check_deprecated_url(response)
return response


@bp.route(f"/{MAP_REST_PATH_NAME}/<mapname>/thumbnail", methods=['GET'])
def get(workspace, mapname):
app.logger.info(f"GET Map Thumbnail, actor={g.user}")
Expand Down
6 changes: 0 additions & 6 deletions src/layman/map/rest_workspace_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ def before_request():
pass


@bp.after_request
def after_request(response):
layman_util.check_deprecated_url(response)
return response


@bp.route(f"/{MAP_REST_PATH_NAME}", methods=['GET'])
def get(workspace):
app.logger.info(f"GET Maps, actor={g.user}")
Expand Down
1 change: 0 additions & 1 deletion src/layman/rest_about.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def get_version():
current_version = upgrade.get_current_version(migration_type)
migrations[f'last-{migration_type}-migration'] =\
f'{current_version[0]}.{current_version[1]}.{current_version[2]}-{current_version[3]}'
migrations['last-migration'] = migrations[f'last-{upgrade.consts.MIGRATION_TYPE_SCHEMA}-migration'] # for backward compatibility
result = {'about': {'applications': {'layman': {'version': clean_version(version),
'release-timestamp': release_date,
},
Expand Down
Loading
Loading