Repository navigation
Expand file tree
/
Copy pathwebhooks.py
More file actions
76 lines (56 loc) · 1.84 KB
/
Copy pathwebhooks.py
File metadata and controls
76 lines (56 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""Webhook models — the registration record and the delivery envelope."""
from __future__ import annotations
from datetime import datetime
from typing import Any, Literal
from stemsplit_python.models._base import BaseSDKModel
from stemsplit_python.models.jobs import (
JobInput,
JobOptions,
JobOutputs,
JobStatus,
)
WebhookEventType = Literal["job.completed", "job.failed"]
class Webhook(BaseSDKModel):
"""A registered webhook subscription.
The ``secret`` field is only populated on the response from
``POST /webhooks`` — listing returns webhooks without their secrets.
"""
id: str
url: str
events: list[str]
is_active: bool = True
fail_count: int = 0
last_error: str | None = None
last_called_at: datetime | None = None
created_at: datetime
secret: str | None = None
class WebhookListResponse(BaseSDKModel):
"""Wire shape of ``GET /webhooks``."""
webhooks: list[Webhook]
class WebhookEventData(BaseSDKModel):
"""The ``data`` block inside a webhook delivery envelope.
Stem-separation jobs and YouTube jobs share this envelope; YouTube
deliveries add ``type="youtube"`` and a video-specific ``input`` block.
"""
job_id: str
status: JobStatus
type: Literal["stem", "youtube"] | None = None
input: JobInput | dict[str, Any] | None = None
options: JobOptions | None = None
outputs: JobOutputs | None = None
credits_charged: int | None = None
error_message: str | None = None
created_at: datetime | None = None
completed_at: datetime | None = None
class WebhookEvent(BaseSDKModel):
"""The verified, parsed webhook delivery."""
event: WebhookEventType
timestamp: datetime
data: WebhookEventData
__all__ = [
"Webhook",
"WebhookEvent",
"WebhookEventData",
"WebhookEventType",
"WebhookListResponse",
]