Esempio n. 1
0
    def serialize_notification_to_context(
            cls, notification: NotificationSpec) -> Dict:
        payload = {
            "message": notification.get_details(),
            "message_format": "text",
            "color": notification.get_color(),
            "from": "Polyaxon",
        }

        return payload
Esempio n. 2
0
 def serialize_notification_to_context(
         cls, notification: NotificationSpec) -> Dict:
     context = {
         "owner": notification.uuid,
         "project": notification.uuid,
         "uuid": notification.uuid,
         "name": notification.name,
         "title": notification.get_title(),
         "details": notification.get_details(),
         "finished_at": notification.condition.last_transition_time,
     }
     return context
Esempio n. 3
0
    def serialize_notification_to_context(cls, notification: NotificationSpec) -> Dict:
        payload = {
            "title": notification.get_title(),
            "text": notification.get_details(),
            "color": notification.get_color(),
            "fields": [],
            "author_name": "Polyaxon",
            "author_link": cls.get_url(notification),
            "author_icon": None,
        }

        return payload
Esempio n. 4
0
    def serialize_notification_to_context(cls, notification: NotificationSpec) -> Dict:
        payload = {
            "event_type": notification.get_title(),
            "description": notification.condition.reason,
            "details": notification.get_details(),
            "incident_key": "trigger",
            "client": "polyaxon",
            "client_url": cls.get_url(),
            "contexts": [],
        }

        return payload
Esempio n. 5
0
    def serialize_notification_to_context(cls, notification: NotificationSpec) -> Dict:
        logo_url = "https://cdn.polyaxon.com/static/v1/images/logo_small.png"
        fields = []  # Use build_field

        payload = {
            "fallback": notification.condition.type,
            "title": notification.get_title(),
            "title_link": cls.get_url(notification),
            "text": notification.get_details(),
            "fields": fields,
            "mrkdwn_in": ["text"],
            "footer_icon": logo_url,
            "footer": "Polyaxon",
            "color": notification.get_color(),
            "ts": to_timestamp(notification.condition.last_transition_time),
        }

        return payload
Esempio n. 6
0
 def get_url(notification: NotificationSpec):
     run_path = notification.get_url_path()
     if not run_path:
         return
     url = "{}/{}".format(clean_host(settings.CLIENT_CONFIG.host), run_path)
     return add_notification_referrer_param(
         url,
         provider="polyaxon",
         is_absolute=False,
     )
Esempio n. 7
0
    def serialize_notification_to_context(
            cls, notification: NotificationSpec) -> Dict:
        logo_url = ""

        payload = {
            "content": notification.get_details(),
            "avatar_url": logo_url
        }

        return payload
 def setUp(self):
     super().setUp()
     self.notification = NotificationSpec(
         kind=self.webhook.notification_key,
         owner="onwer",
         project="project",
         uuid=uuid.uuid4().hex,
         name="test",
         condition=V1StatusCondition(
             type=V1Statuses.FAILED,
             reason="reason",
             message="message",
             last_update_time=now(),
             last_transition_time=now(),
         ),
     )