pygeoapi icon indicating copy to clipboard operation
pygeoapi copied to clipboard

support for transactions

Open pvgenuchten opened this issue 6 years ago • 13 comments

Ability to delete, insert, update or patch features from the api OGC-API-Features currently does not offer a specification for transactions yet However Openapi typically uses DELETE, POST and PUT verbs to update content in an API, so I don't expect much deviation to this in the upcoming ogc api's. It could actually support the discussion there to have an initial implementation available.

Transactions should be disabled by default, and only activated if proper authorisation is in place

Create feature

POST /items/{id} [obj]

Update feature

PUT /items/{id} [obj]

Delete feature

DELETE /items/{id}

Patch feature (partial update)

PATCH /items/{id} [partial obj]

pvgenuchten avatar May 12 '19 09:05 pvgenuchten

Makes sense. I imagine that functionality will be provider specific/dependent and that our provider base class would throw NotImplementedError by default.

tomkralidis avatar May 12 '19 12:05 tomkralidis

Create feature

POST /items/ [obj]

ID should not be forced while feature creation?

ID should be returned

jachym avatar Oct 08 '19 09:10 jachym

My $2ct: The "id thing" requires some thinking-through: it needs to be unique within a Collection on one hand, so IMHO cannot be enforced on the client (think of multiple clients POST/PUTing at the same time), unless maybe with UUIDs. WFS2 had an idgen option, remember? "The idgen attribute control how a WFS generates identifiers from newly created feature instances using the Insert action. The default action is to have the WFS generate a new id for the features. This is also backward compatible with WFS 1.0 where the only action was for the WFS to generate an new id. Don't know if we need this flexibility/complexity, just wanted to mention. A use case for client-supplied id's are e.g. Cadastral Parcel id's (or INSPIRE-ids brr). Or in SensorWeb: station-ids.

Another example: With SensorThings API Transactions, when POSTing a Thing, the server always generates a unique id (within the Things Collection), but at same time allows a client to set a client-unique field, e.g. a station id within a free-form properties hashmap. So a client can always find back its Things (this was a severe limitation in SOS). Best of both worlds but then again STA has a fixed abstract entity model like an appschema.

justb4 avatar Oct 08 '19 11:10 justb4

btw The STAC Pilot Transaction spec (to which OAPIF refers, see above) is IMHO not really clear on this: one POSTs an Item to a Collection and probably if the Item contains an id it is validated for uniqueness and used, otherwise generated (?), but id is mandatory in Item (?). That could be a simple solution without idgen...

justb4 avatar Oct 08 '19 11:10 justb4

About the POST /item[s]/[uuid]

It IMHO should return 404, since the endpoint does not exist yet. I have nothing against having required [uu]id in the body of the request

jachym avatar Oct 08 '19 12:10 jachym

POST /collections/{collectionID}/items with a body of Item or even FeatureCollection (have seen latter somewhere, MapFish API?). Item already has an id-field (cannot find back if id is indeed mandatory, seems not in OAPIF. "id is a local identifier of the feature" and ... that strictly only the URI needs to be unique.

Some sources indicate that PUT should be used to add (if Entity not exists) or replace (if exists) a specific Entity (in our case Item): https://restfulapi.net/rest-put-vs-post/

So

POST /collections/{collectionID}/items [obj]

Adds (new) Item (Feature) to the collection.

and

PUT  /collections/{collectionID}/items/{featureId} [obj]

would add or replace an Item with specific URI (id?).

Update: saw a more recent link to the Stac spec in Gitter from @cholmes, the above aligns with this: https://github.com/radiantearth/stac-spec/tree/master/api-spec/extensions/transaction

justb4 avatar Oct 08 '19 13:10 justb4

@justb4 I would also consider PATCH to change only a feature property:

PATCH /collections/{collectionID}/items/{featureId} [obj]

would change the field value of an item, it could also be the geometry

francbartoli avatar Dec 03 '19 17:12 francbartoli

@francbartoli thanks, yes PATCH for partial updates (except for id itself IMHO) should be considered.

justb4 avatar Dec 04 '19 11:12 justb4

Sure @justb4, except the feature identifier

francbartoli avatar Dec 04 '19 12:12 francbartoli

Note: transactions draft now at http://docs.opengeospatial.org/DRAFTS/20-002.html

tomkralidis avatar Apr 22 '20 14:04 tomkralidis

Thanks @tomkralidis, very good reference to follow for the implementation

francbartoli avatar Apr 22 '20 14:04 francbartoli

What is the status here?

p1d1d1 avatar Oct 28 '21 09:10 p1d1d1

For now, we continue to monitor the OGC draft for developments, contributions against are welcome.

tomkralidis avatar Oct 28 '21 14:10 tomkralidis

Implemented in #984

tomkralidis avatar Jan 11 '23 20:01 tomkralidis