ropensci / ruODK

ruODK: An R Client for the ODK Central API
https://docs.ropensci.org/ruODK/
GNU General Public License v3.0
41 stars 12 forks source link

Support entities #152

Open florianm opened 4 months ago

florianm commented 4 months ago

Feature

Support all API endpoints relevant to entities.

Test data

https://docs.getodk.org/central-api-dataset-management/

https://docs.getodk.org/central-api-entity-management/

https://docs.getodk.org/central-api-odata-endpoints/#odata-dataset-service

Small jobs

Discussion points

roammi commented 3 months ago

thank you @florianm for all the great work for this, I have an use case and I will be looking forward for it to try it out

florianm commented 3 months ago

Oh that's great to hear, @roammi! I'm carving out some time for ruODK, so things are moving forward again.

Do you feel your use case (if appropriate, simplified and de-identified) could be used in a vignette as an example to other ruODK users?

florianm commented 3 months ago

Entity Lists are now supported, Entities coming soon.

roammi commented 3 months ago

Oh that's great to hear, @roammi! I'm carving out some time for ruODK, so things are moving forward again.

Do you feel your use case (if appropriate, simplified and de-identified) could be used in a vignette as an example to other ruODK users?

Yes I do, We will need to put it to work first, but it sounds great, I will be using the update entity function, I'll wait for the new release of ruodk to try it out, or is it a way to try [dataset_update] earlier?

florianm commented 3 months ago

@roammi you can try out entitylist_update right now if you install the latest version of ruODK (see Readme) and update your ODKC_VERSION (see NEWS).

In consultation with the core team ruODK uses the term entitylist for datasets.

Are you saying that you would like to use https://docs.getodk.org/central-api-entity-management/#updating-an-entity ? I will work on that one next then so you can try it out right away.

roammi commented 3 months ago

@roammi you can try out entitylist_update right now if you install the latest version of ruODK (see Readme) and update your ODKC_VERSION (see NEWS).

In consultation with the core team ruODK uses the term entitylist for datasets.

Are you saying that you would like to use https://docs.getodk.org/central-api-entity-management/#updating-an-entity ? I will work on that one next then so you can try it out right away.

thank you @florianm I have the latest version and it worked succesfully! thank you for the hard work! I've used ruODK::entitylist_list(), ruODK::entitylist_detail() ruODK::entitylist_download() image

I also used bruno API and test it create, delete and update an entity succesfully so will be great to test it with ruODK. The challenge for update is the baseVersion, you have check the version and increase it by 1 each time making the update, it will be really great to do that natively in ruODK but it could be handled outside in R too

lognaturel commented 3 months ago

The challenge for update is the baseVersion, you have check the version and increase it by 1 each time making the update, it will be really great to do that natively in ruODK but it could be handled outside in R too

You also have the option of using the force query parameter as described in https://docs.getodk.org/central-api-entity-management/#updating-an-entity

If your updates are bringing in values from an external source of truth, it generally makes sense to force the update.

baseVersion exists to detect parallel updates from multiple clients which is especially likely in an offline context. If you’re running a script that is online, it should also generally be appropriate to use the force flag. If your updates are based on the prior version of an entity, you should be able to pull the entity and then update it almost immediately meaning you don’t have to worry about conflicting updates between the two actions unless your context is extremely dynamic.

If you intend to use baseVersion, you shouldn’t have to do any incrementing, you should be able to take the existing value for __version of the entity you want to update and use that as baseVersion for your update. If that’s what you plan on doing, I’d be interested in learning more about what you’re doing with the API and why forcing the update wouldn’t be appropriate for you.

(I’m an ODK maintainer. We can also take this to the ODK forum, sorry about going a bit off topic, @florianm!)

florianm commented 3 months ago

As always, the insight is highly appreciated, @lognaturel!

I'll have to digest the above a bit. Maybe ruODK could default to use the force=true flag.