integrations.py 1001 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from __future__ import annotations
  2. from typing import Union
  3. from pydantic import Field, TypeAdapter
  4. from typing_extensions import Annotated
  5. from ._generated import SlackIntegrationFields, WebhookIntegrationFields
  6. class SlackIntegration(SlackIntegrationFields):
  7. team_name: str
  8. """Slack workspace (not W&B team) where this integration will post messages."""
  9. channel_name: str
  10. """Slack channel where this integration will post messages."""
  11. class WebhookIntegration(WebhookIntegrationFields):
  12. name: str
  13. """The name of this webhook integration."""
  14. url_endpoint: str
  15. """The URL that this webhook will POST events to."""
  16. Integration = Annotated[
  17. Union[SlackIntegration, WebhookIntegration],
  18. Field(discriminator="typename__"),
  19. ]
  20. # INTERNAL USE ONLY: For parsing integrations from paginated responses
  21. IntegrationAdapter: TypeAdapter[Integration] = TypeAdapter(Integration)
  22. __all__ = [
  23. "Integration",
  24. "SlackIntegration",
  25. "WebhookIntegration",
  26. ]