mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-01-05 16:19:43 -06:00
Fe overhaul docs (#1640)
* api changes * doc changes * move docs * generated * generate * pkg * backmerge main * revert to main * revert main * race? * remove go tests
This commit is contained in:
36
examples/python/cron/programatic-sync.py
Normal file
36
examples/python/cron/programatic-sync.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
from hatchet_sdk import Hatchet
|
||||
|
||||
hatchet = Hatchet()
|
||||
|
||||
|
||||
class DynamicCronInput(BaseModel):
|
||||
name: str
|
||||
|
||||
|
||||
dynamic_cron_workflow = hatchet.workflow(
|
||||
name="CronWorkflow", input_validator=DynamicCronInput
|
||||
)
|
||||
|
||||
# > Create
|
||||
cron_trigger = dynamic_cron_workflow.create_cron(
|
||||
cron_name="customer-a-daily-report",
|
||||
expression="0 12 * * *",
|
||||
input=DynamicCronInput(name="John Doe"),
|
||||
additional_metadata={
|
||||
"customer_id": "customer-a",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
id = cron_trigger.metadata.id # the id of the cron trigger
|
||||
|
||||
# > List
|
||||
cron_triggers = hatchet.cron.list()
|
||||
|
||||
# > Get
|
||||
cron_trigger = hatchet.cron.get(cron_id=cron_trigger.metadata.id)
|
||||
|
||||
# > Delete
|
||||
hatchet.cron.delete(cron_id=cron_trigger.metadata.id)
|
||||
Reference in New Issue
Block a user