Note: Right now webhook is a meta model which is not persisted in the database. Attribute: name: Webhook name - maps to the URL path (e.g. st2/ or my/webhook/one).
| 21 | |
| 22 | |
| 23 | class WebhookDB(stormbase.StormFoundationDB, stormbase.UIDFieldMixin): |
| 24 | """ |
| 25 | Note: Right now webhook is a meta model which is not persisted in the database. |
| 26 | |
| 27 | Attribute: |
| 28 | name: Webhook name - maps to the URL path (e.g. st2/ or my/webhook/one). |
| 29 | """ |
| 30 | |
| 31 | RESOURCE_TYPE = ResourceType.WEBHOOK |
| 32 | UID_FIELDS = ["name"] |
| 33 | |
| 34 | name = me.StringField(required=True) |
| 35 | |
| 36 | def __init__(self, *args, **values): |
| 37 | super(WebhookDB, self).__init__(*args, **values) |
| 38 | self.name = self._normalize_name(name=self.name) |
| 39 | self.uid = self.get_uid() |
| 40 | |
| 41 | def _normalize_name(self, name): |
| 42 | # Remove trailing slash if present |
| 43 | if name.endswith("/"): |
| 44 | name = name[:-1] |
| 45 | |
| 46 | return name |