Ejemplo n.º 1
0
 def extract(self, value: Any) -> Any:
     if value is None:
         return value
     if self.is_datetime:
         return to_timestamp(value)
     if self.is_uuid and not isinstance(value, str):
         return value.hex
     return self.attr_type(value)
Ejemplo n.º 2
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
Ejemplo n.º 3
0
 def serialize(
     self,
     dumps: bool = False,
     include_actor_name: bool = True,
     include_instance_info: bool = False,
 ) -> Union[str, Dict]:
     _data = self.data
     if not include_actor_name and self.actor and self.actor_name in _data:
         _data = copy.deepcopy(self.data)
         _data.pop(self.actor_name)
     data = {
         "uuid": self.uuid.hex,
         "timestamp": to_timestamp(self.datetime),
         "type": self.event_type,
         "ref_id": self.ref_id.hex if self.ref_id else None,
         "data": _data,
     }
     if include_instance_info:
         data["instance_id"] = self.instance_id
         data["instance_contenttype"] = self.instance_contenttype
     return dumps_htmlsafe(data) if dumps else data