integrations.py 972 B

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