-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
GNIP 93: Allowing changes to the dataset attributes table via REST API #10873
Comments
I see the need for these capabilities. We are researching how an attribute value update would be possible via DRF and REST. @kilichenko-pixida will post some of his findings soon. |
As mentioned, I am working on this in this issue. As of now, I am not adding a separate endpoint for the attributes, I think I found a way to update them through the PATCH api/v2/dataset/<dataset_id>. I didn't figure out what kind of JSON payload might just work out of the box with the DRF serizlizers for this type of nested field, so instead of passing it as I am also preparing a geonodectl command which would allow to pass a JSON file like |
@gannebamm @ridoo @mwallschlaeger Here is a summary of the relevant changes that already happened. I been working on this issue and it resulted in two already merged PRs: one to geonode to add the attrtibute processing ability and another to geonodectl to make patching from JSON files possible in geonodectl as mentioned in this issue. As per testing in the dev environment, patching of attributes is now possible, but current implementation might not be a good solution for a direct use of the API as described in this GNIP. The reason is that currently the attribute_set values needs to be passed wrapped in a "data" field which allows to bypass internal DRF validation and access it from the This "wrapping" is done automatically when patching attributes from the geonodectl, but that makes patching directly through the API not obvious (though now at least possible). Details on why it was done this way could be found in the discussion on the first PR to geonode - TLDR We don't know how to do it, but it might turn out to be trivial. |
Hi @gannebamm @kilichenko-pixida @ridoo @mwallschlaeger I was checking the issue and I have a couple of notes about the implementation. attributes as a modelThe field attributes serve a purpose and come from Geoserver. Therefore, we must handle them with care. For example, we retrieve the attribute name and type from Geoserver through a function: geonode/geonode/geoserver/helpers.py Lines 991 to 1105 in cdeb2d9
and later set with this function: geonode/geonode/geoserver/helpers.py Lines 913 to 988 in cdeb2d9
in the end, they must always be coherent with Geoserver and the original dataset Api implementationSometimes working with dynamic rest is a headache, I agree. The field always expects a list of IDs rather than a payload to update the values.
This function seems like a workaround solution, which might not be the best approach in case we need to work with another field in the future. We define a specific action and extend_schema in the viewset, allowing the user to add a schema to the API without creating a new URL. For example, the geonode/geonode/base/api/views.py Lines 1390 to 1481 in cdeb2d9
In this function, all the code required to add, delete, update, and handle the extra_metadata attribute for the resource is defined. The corresponding endpoint will be I would suggest having a similar approach for handling the attribute. This will have several benefits:
|
@mattiagiupponi thanks for your feedback. I am getting more and more into the rest_framework stuff. There is so much "magic" underneath .. once you have cases which diverge from the "normal" (tm) ones, you'd need much deeper understanding of how all works. In this specific case, I would be curious how you plan to do edits via the REST API when dropping the legacy metadata editor templates. If you plan to re-use the API v2 (which I assume you will) we should revise it with regard to such changes. To my current understanding, the API v2 is too limited to accept all necessary metadata changes of a dataset, right? |
We are still evaluating how change it, but for sure some API changes might be required |
@ridoo we're speaking of dataset attributes, not metadata in general here, right? |
GNIP 93 - Allowing changes to the dataset attributes table via REST API
Overview
I guess this might be to small for a GNIP, but it might require a discussion of the PSC.
Currently making changes to the attribute table of a dataset is only possbile via the Advanced Metadata Editor form. To further restify GeoNode it would be nice have the possibility to change attributes via the REST API.
Proposed By
@mwallschlaeger : Marcel Wallschlaeger
Assigned to Release
This proposal is for GeoNode 4.1.
State
Motivation
The main motivation for us is requirement to upload data into our GeoNode instance using an external service only communicating to GeoNode through the REST API. Therefor to set or change attributes of a dataset this workflow requires the attribute manipulation via REST interface.
Proposal
Currently the Dataset REST endpoint has a
read_only
field for the attributes. In my opinion I would leave this construct as it is. and add another endpoint below the Dataset. Something like:Which handles the changes to the attributes of a dataset. This Endpoint would allow to change the
"description", "attribute_label", "visable", "featureinfo_type, "display_order"
.Backwards Compatibility
I dont think so.
Future evolution
For our specific usecase we further want to add fields to the
Attributes
models which might be interesting for the whole GeoNode. This would be "unit" and "keywords" for a column so in a later implementation users could find dataset including a specific type of attribute inside of a dataset. This would allow to make dashboards and stories to compare same units and keyword tags of different datasets more easy.Feedback
Update this section with relevant feedbacks, if any.
Voting
Project Steering Committee:
Links
The text was updated successfully, but these errors were encountered: