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 trigger type reference based filtering to the /v1/triggerinstances API endpoint #4151

Merged
merged 4 commits into from
May 29, 2018

Conversation

Kami
Copy link
Member

@Kami Kami commented May 29, 2018

This pull request adds TriggerType reference based filtering to the /v1/triggerinstances API endpoint as discussed with @enykeev.

Example usage - curl http://127.0.0.1:9101/v1/triggerinstances?trigger_type=core.st2.generic.actiontrigger.

Note on the implementation detail - We only store Trigger reference on the TriggerInstance object so to be able to filter on TriggerType reference we need to do that via Trigger reference on the TriggerInstance object.

In relational database that would be a simple join and in non-relational database that would be a simple query in case Trigger is correctly denormalized and trigger reference also stored on the TriggerInstance object (that's not the case for our schema right now).

Recent versions of MongoDB also support simple aggregate queries and joins, but our API filtering code is not designed to support it yet so I went with a simpler "two queries" approach.

That works fine in this scenario because there will likely never be many thousand of Trigger objects in the database.

@Kami Kami added this to the 2.8.0 milestone May 29, 2018
@Kami Kami requested a review from enykeev May 29, 2018 08:41
@Kami Kami merged commit 23e2d2f into master May 29, 2018
@Kami Kami deleted the trigger_instance_filter_trigger_type branch May 29, 2018 09:39
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