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

Request movement- and reproduction-history of a single animal #493

Open
AndreasSchultzGEA opened this issue Oct 25, 2024 · 10 comments
Open

Comments

@AndreasSchultzGEA
Copy link
Collaborator

Users of our interfaces of request for getting the history of a single animal at once instead of requesting several endpoint without proper filtering.
And - in our own business - we often have to request the history of single animals as well from national cattle-register to insert them in complete into our database, but some of them limit the data to be delivered by the dedicated endpoints in concerns of date/time probably for performance/payload reasons.
#492

@dirbSEGES
Copy link

Hi, my point of view is that it could be a solution to add a single animal as request parameter on all relevant message. like this ex.
/Locations/dk.herdnumber/25872/dk.animalnumber/2587210201/diagnoses
That is how we have solve this issue when a new animal is entering the herd.

Then you can request the history of a new animal entering the location.

If a new endpoint for history is made, we have to add all event messages into one new endpoint. This will be another kind approach of sharing data then the existing.

@AndreasSchultzGEA
Copy link
Collaborator Author

AndreasSchultzGEA commented Oct 31, 2024

Thanks Ditlev for your comment.
If we provide interface which are not defined in the standard so far, we mostly design them the other way round:
/locations/dk.herdnumber/25872/diagnoses/dk.animalnumber/2587210201
This way, it is somehow an addition or a kind of filter for the well know standard-url

Nevertheless, a disadvantage is, that one has to request all endpoints to get the data of one single animal collected --> one request vs.

  • 4*movement + 5-6*reproduction + x*health + y*diagnoses + ...

Really a lot of complexity! Each of this requests could fail, deliver a bad request, all of them have to be collected, etc.

@dirbSEGES
Copy link

If it will be an single endpoint where you can get all event of an animal, what is the reason to have all the other endpoints? Then this endpoint only can be use by single animal, right?

@cookeac
Copy link
Collaborator

cookeac commented Oct 31, 2024

We agreed that @AndreasSchultzGEA will propose a pull request that demonstrates filtering the existing API end points by animal identifier as @dirbSEGES proposed. This may be easier for people to implement serialisation and deserialisation of resources, even though it requires more calls. It may also allow collection of missing events of a single type for an animal.

@AndreasSchultzGEA
Copy link
Collaborator Author

I provided 2 slightly differing PR:
SEGES-style: #498
Filter-style: #499

@erwinspeybroeck
Copy link
Collaborator

I'm in favour of the filter style --> is conform with API design rules --> the endpoint in the example is pregancy -checks, and you want this for one animal, or you want a specifc period, or a modified-since, or only those with value true ....
The animal is just another filter.
We mostly add something like animals before the scheme and id, because you have to identify what you are filtering.

/location/pregnancy-checks/animals/scheme/id
to avoid misunderstanding with other filtering

@cookeac
Copy link
Collaborator

cookeac commented Nov 27, 2024

Discussed at Nov 27 meeting

  • We prefer an API per event type rather than a potentially expanding multi-event API
  • We prefer the filter method ?animal-scheme=x&animal-id=y

@cookeac
Copy link
Collaborator

cookeac commented Nov 28, 2024

Discussed at Nov 28 meeting

  • We also prefer the filter method with query parameters
  • If a server does not recognise these parameters (backwards compatibility) they will return the full set - no filtering
  • If a server decides it will not support these parameters it can provide an HTTP error.

@AndreasSchultzGEA
Copy link
Collaborator Author

AndreasSchultzGEA commented Nov 28, 2024

Good solution. I thought of it as well, but then I had to prepare a third PR.
Now, I have to ;-)

What about

  • "?eu.animalId=DK2138349874984"
    instead of
  • "?animal-scheme=x&animal-id=y"

The advantage is to have only one parameter (key-value) instead of two.

@damare
Copy link
Collaborator

damare commented Dec 10, 2024

As the scheme-id can literally be anything, it is not possible to define this in openAPI. Moreover, most frameworks do not allow dynamic query parameters for security reasons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants