Prefect Cloud REST API: Query Automations related ...
# prefect-cloud
t
Prefect Cloud REST API: Query Automations related to a deployment We are looking into integrating trigger definitions for deployment execution in our CI pipeline. Deploying the automation based on the trigger definition in the
deployment.yaml
is straightforward. But how do we remove the automation again on deployment removal? One thought is to retrieve the automatons related to a deployment via the REST API and then remove them (via script). This information is already shown in the Prefect UI (see screenshot). However, I could not find an API call that makes this possible. Any ideas?
c
These are currently populated when deploying flows via the trigger definitions embedded in your YAML files. (i.e. they won't pick up automations that are using a deployment in a
run-deployment
action, for example)
t
Hey Chris, that sounds great. Thanks for the speedy answer! I will give it a try!
l
Hi, I have another question related to this. I've searched the docs and also here in slack but couldn't find anything. Adding triggers to deployment section of my prefect.yaml worked nicely but I couldn't change the action type here. Its always set to RunDeployment. Is it possible to specify actions [what we see in the RESTAPI automations endpoint] like send notification here in the yaml as well? For eg: With a yaml like below, it still creates rundeployment action here. Is this not a valid section here?
Copy code
deployments:
- entrypoint: my_project/flow.py:main
  name: foo
  triggers:
  - name: Custom Trigger
    enabled: true
    type: event
    expect:
    - prefect.flow-run.Completed
    match:
      prefect.resource.id: prefect.flow-run.*
    actions:
      - type: send-notification
        block_document_id: bf277aeb-k6ab-4j47-8ee9-ib2454aa1234
        subject: test
        body: some message
I got the idea to add actions from the doc here although its not clear if its just a yaml file or the prefect.yaml file. But dedenting it didn't make any difference either