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

feat: HTTP Trigger #79

Merged
merged 2 commits into from
Dec 5, 2023
Merged

feat: HTTP Trigger #79

merged 2 commits into from
Dec 5, 2023

Conversation

loicmathieu
Copy link
Member

Fixes kestra-io/kestra#2299

Flow to test the new trigger:

id: http-trigger
namespace: dev

triggers:
  - id: http
    type: io.kestra.plugin.fs.http.Trigger
    uri: https://api.chucknorris.io/jokes/random
    responseCondition: "{{ response.statusCode == 200 }}"

tasks:
  - id: hello
    type: io.kestra.core.tasks.log.Log
    message: Kestra team wishes you a great day! 👋

@anna-geller
Copy link
Member

why response instead of trigger.statusCode? just thinking whether this is not confusing where the response variable is coming from as it's usually trigger.XYZ

Copy link
Member

@anna-geller anna-geller left a comment

Choose a reason for hiding this comment

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

forget my previous comment, this makes sense, the trigger variables can be used in tasks - sorry, my misinterpretation

works!

id: http-trigger
namespace: dev


tasks:
  - id: hello
    type: io.kestra.core.tasks.log.Log
    message: "{{trigger.body}}"

triggers:
  - id: http
    type: io.kestra.plugin.fs.http.Trigger
    uri: https://api.chucknorris.io/jokes/random
    responseCondition: "{{ response.statusCode == 200 }}"
    interval: PT30S

@loicmathieu
Copy link
Member Author

The trigger variables are normally to use in the triggered Flow tasks as you noticed, here we evaluate the trigger.
So I decided to call it response as it's a variable only usable when evaluating the trigger property responseCondition.

However, I can rename it.

I can also totally remove the responseCondition property and only rely on the standard conditions property where you can use a condition of type VariableCondition. But I found it more logical to define the evaluation condition like this. The responseCondition will be evaluated prior to any standard trigger conditions.

@loicmathieu loicmathieu requested a review from Skraye December 4, 2023 09:11
Copy link
Member

@Skraye Skraye left a comment

Choose a reason for hiding this comment

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

Small indent detail, however LGTM

src/main/java/io/kestra/plugin/fs/http/AbstractHttp.java Outdated Show resolved Hide resolved
@loicmathieu loicmathieu merged commit 40dc889 into master Dec 5, 2023
1 check passed
@loicmathieu loicmathieu deleted the feat/http-trigger branch January 3, 2024 13:37
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.

Add HTTP Trigger
3 participants