From ee1f0f4f5e93a930cde0c30db383a7a37c5ceeeb Mon Sep 17 00:00:00 2001 From: Tom Kralidis Date: Sat, 15 Feb 2025 15:11:53 -0500 Subject: [PATCH] OGC API: add support for collection level transactions --- owslib/ogcapi/features.py | 53 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/owslib/ogcapi/features.py b/owslib/ogcapi/features.py index 0cec6f07..1b87f8b1 100644 --- a/owslib/ogcapi/features.py +++ b/owslib/ogcapi/features.py @@ -53,6 +53,57 @@ def collection_queryables(self, collection_id: str) -> dict: path = f'collections/{collection_id}/queryables' return self._request(path=path) + def collection_create(self, data: str) -> bool: + """ + implements POST /collections + + @type collection_id: string + @type data: string + @param data: collection data + + @returns: single collection result + """ + + path = 'collections' + + self.headers['Content-Type'] = 'application/json' + + _ = self._request(method='POST', path=path, data=data) + + return True + + def collection_update(self, collection_id: str, data: str) -> bool: + """ + implements PUT /collections/{collectionId} + + @type collection_id: string + @param collection_id: id of collection + @type data: string + @param data: collection data + + @returns: ``bool`` of update result + """ + + path = f'collections/{collection_id}' + _ = self._request(method='PUT', path=path, data=data) + + return True + + def collection_delete(self, collection_id: str) -> bool: + """ + implements DELETE /collections/{collectionId} + + @type collection_id: string + @param collection_id: id of collection + + @returns: ``bool`` of deletion result + """ + + path = f'collections/{collection_id}' + _ = self._request(method='DELETE', path=path) + + return True + def collection_items(self, collection_id: str, **kwargs: dict) -> dict: """ implements /collection/{collectionId}/items @@ -145,7 +196,7 @@ def collection_item_update(self, collection_id: str, identifier: str, @type data: string @param data: raw representation of data - @returns: ``bool`` of deletion result + @returns: ``bool`` of update result """ path = f'collections/{collection_id}/items/{identifier}'