<@ULVA73B9P> Is there a python SDK function that a...
# ask-marvin
r
@Marvin Is there a python SDK function that allows me to get all events fitting some filter conditions?
m
In Prefect 3.x, you can filter events using the
match
and
match_related
fields to define your filter conditions. These fields allow you to filter events based on the contents of their
resource
and
related
fields. Each label added to a
match
filter is combined using an AND operation, and can accept either a single value or a list of values that are combined using an OR operation. For more details on how to configure these filters, you can refer to the Prefect documentation on custom triggers. If you're looking for a specific SDK function to retrieve events based on these filters, you may need to explore the Prefect API further or implement a custom solution using these filtering capabilities.
r
Is there an SDK function that hits the POST /api/events/filter endpoint on prefect server?
@Marvin Is there an SDK function that hits the POST /api/events/filter endpoint on prefect server?
m
It seems that the Prefect 3.x documentation does not explicitly mention a Python SDK function for directly hitting the
POST /api/events/filter
endpoint. However, Prefect provides a general client interface,
get_client
, that you might use to interact with the Prefect API programmatically. Here's a basic idea of how you might use the client to interact with the API:
Copy code
python
from prefect import get_client

async def filter_events(payload):
    async with get_client() as client:
        response = await <http://client.post|client.post>("/api/events/filter", json=payload)
        return response.json()

# Example usage
# asyncio.run(filter_events(your_payload))
You would need to replace
your_payload
with the appropriate JSON payload for your filtering conditions. For more information about events and how they can be managed, you can check the Prefect documentation on events.