From d31681eb3b09451cb66213c88365ebf3fed554f3 Mon Sep 17 00:00:00 2001 From: Daniel Abraham Date: Tue, 20 Aug 2024 19:25:20 +0300 Subject: [PATCH] Move quickstart from samples (#48) --- README.md | 1 + quickstart/README.md | 6 ++++++ quickstart/autokitteh.yaml | 23 +++++++++++++++++++++++ quickstart/program.py | 17 +++++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 quickstart/README.md create mode 100644 quickstart/autokitteh.yaml create mode 100644 quickstart/program.py diff --git a/README.md b/README.md index a65accd1..703ffdb4 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ projects for: | 🐍 [Google Forms to Jira](./google_forms_to_jira/) | Poll a form for responses and create an issue for each one | Google Forms → Jira | | 🐍 [Jira assignee from schedule](./jira_google_calendar/assignee_from_schedule/) | Assign new Jira issues to the current on-caller based on a schedule in a shared calendar | Jira ↔ Google Calendar | | 🐍 [Jira deadline to event](./jira_google_calendar/deadline_to_event/) | Create/update calendar events based on the deadlines of Jira issues | Jira ↔ Google Calendar | +| 🐍 [Quickstart](./quickstart/) | Basic workflow for tutorials | HTTP | | ⭐ [Pull Request Review Reminder (Purrr)](./purrr/) | Streamline code reviews and cut down turnaround time to merge pull requests | GitHub ↔ Slack | | ⭐ [ReviewKitteh](./reviewkitteh/) | Monitor pull requests, and meow at random people | GitHub, Google Sheets, Slack | | 🐍 [Task chain](./task_chain/) | Run a sequence of tasks with fault tolerance | Slack | diff --git a/quickstart/README.md b/quickstart/README.md new file mode 100644 index 00000000..fb686b31 --- /dev/null +++ b/quickstart/README.md @@ -0,0 +1,6 @@ +# Quickstart + +Basic workflow for tutorials. + +Used in https://docs.autokitteh.com/get_started/quickstart and in +https://docs.autokitteh.com/get_started/client/cli/quickstart. diff --git a/quickstart/autokitteh.yaml b/quickstart/autokitteh.yaml new file mode 100644 index 00000000..7ce48406 --- /dev/null +++ b/quickstart/autokitteh.yaml @@ -0,0 +1,23 @@ +# This YAML file is a declarative manifest that describes +# the minimal setup of an AutoKitteh project. + +version: v1 + +project: + name: quickstart + connections: + - name: http_conn + integration: http + triggers: + - name: http_get + connection: http_conn + event_type: get + data: + path: trigger_path + call: program.py:on_http_get + - name: http_get_with_param + connection: http_conn + event_type: get + data: + path: iterations/{iters} + call: program.py:on_http_get diff --git a/quickstart/program.py b/quickstart/program.py new file mode 100644 index 00000000..696a3a7d --- /dev/null +++ b/quickstart/program.py @@ -0,0 +1,17 @@ +"""Basic handler for incoming HTTP GET requests.""" + +import time + + +FIVE_SECONDS = 5 + + +def on_http_get(event): + print(f"Received {event.data.method} request") + + iterations = int(event.data.params.get("iters", "0")) + for i in range(iterations): + print("Loop iteration: %d of %d" % (i + 1, iterations)) + time.sleep(FIVE_SECONDS) + + print(f"Finished processing {event.data.method} request")