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

Add endpoint for manipulating incident tags only #291

Merged
merged 3 commits into from
Jun 14, 2021

Conversation

hmpf
Copy link
Contributor

@hmpf hmpf commented May 11, 2021

The new endpoint lists all tags for an incident with GET, you can POST a new tag or DELETE an existing one and for completion's sake you can GET a single tag.

Works in the swagger-ui sp can be played with there.

The IncidenTagRelation model is hidden away, this endpoint only operates with "key=value"-strings.

To be improved: tests, no hardcoding of the equals-sign, maybe use django-nested-routers instead of manually writing the urls.

Copy link
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Couple of comments:

  • I get a 500 error and a traceback if I use "invalid" tag syntax for a GET operation, like incidents/42/tags/foo
  • I wish you would consider Simplify the tag data structure required by the Incident API endpoint #136 when working on adding tag related APIs. I.e. it's one thing the backend data model for tags is over-engineered, we can still simplify the API and change the backend model later...

@hmpf
Copy link
Contributor Author

hmpf commented May 11, 2021

  • I get a 500 error and a traceback if I use "invalid" tag syntax for a GET operation, like incidents/42/tags/foo

Yeah that should have a better error code.. 404 might do in this specific case?

We can't really simplify the API while still being on version 1, but I guess I can make a simplified API for version 2 and make version 2 visible? Then you can adapt the API client library. Different PR, though, that.

One thing I disagree with the designers of drf is nesting. I think that every attribute on a model is also a resource in and of itself, that should have its own endpoint and full CRUD if relevant. An API should hide the implementation, not be a thin veneer on top.

@lunkwill42
Copy link
Member

  • I get a 500 error and a traceback if I use "invalid" tag syntax for a GET operation, like incidents/42/tags/foo
    Yeah that should have a better error code.. 404 might do in this specific case?

404 is good enough: There is no such tag.

(Either that, or a client error should be issued)

We can't really simplify the API while still being on version 1, but I guess I can make a simplified API for version 2 and make version 2 visible? Then you can adapt the API client library. Different PR, though, that.

Yes, I agree. This interface is perfectly in line with API v1, but we should add this to #136 or maybe make a comment to #295.

In summary:

  • Fix the 500 error (use 404)
  • Fix the merge conflict

And: Are we still updating the endpoint docs, now that we have swagger?

@hmpf
Copy link
Contributor Author

hmpf commented Jun 9, 2021

Are we still updating the endpoint docs, now that we have swagger?

The goal should be that we don't have to but it can be fiddly to get the swagger right. Moving the free text docs so that swagger picks up on it would be wise though. (By using docstrings, basically.)

@hmpf hmpf force-pushed the tags-endpoint branch from e523136 to f4a2790 Compare June 9, 2021 12:24
@hmpf hmpf requested a review from lunkwill42 June 9, 2021 12:27
@hmpf
Copy link
Contributor Author

hmpf commented Jun 9, 2021

Invalid tags now lead to a 404, the merge conflict is fixed, and it's rebased on master.

@hmpf hmpf marked this pull request as ready for review June 9, 2021 12:51
Copy link
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you :)

@hmpf hmpf merged commit 100ded5 into Uninett:master Jun 14, 2021
@hmpf hmpf deleted the tags-endpoint branch June 14, 2021 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants