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

Adding an account-level event subscriber #12808

Merged
merged 9 commits into from
Apr 23, 2024
28 changes: 28 additions & 0 deletions src/prefect/events/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,3 +571,31 @@ def __init__(
)

self._api_key = api_key


class PrefectCloudAccountEventSubscriber(PrefectCloudEventSubscriber):
def __init__(
self,
api_url: Optional[str] = None,
api_key: Optional[str] = None,
filter: Optional["EventFilter"] = None,
reconnection_attempts: int = 10,
):
"""
Args:
api_url: The base URL for a Prefect Cloud workspace
api_key: The API of an actor with the manage_events scope
reconnection_attempts: When the client is disconnected, how many times
the client should attempt to reconnect
"""
api_url, api_key = _get_api_url_and_key(api_url, api_key)

account_api_url, _, _ = api_url.partition("/workspaces/")
chrisguidry marked this conversation as resolved.
Show resolved Hide resolved

super().__init__(
api_url=account_api_url,
filter=filter,
reconnection_attempts=reconnection_attempts,
)

self._api_key = api_key
Loading