transcodely 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- buf/__init__.py +0 -0
- buf/validate/__init__.py +0 -0
- buf/validate/validate_pb2.py +469 -0
- buf/validate/validate_pb2.pyi +651 -0
- transcodely/__init__.py +175 -0
- transcodely/_codec/__init__.py +0 -0
- transcodely/_codec/json_codec.py +193 -0
- transcodely/_transport/__init__.py +0 -0
- transcodely/_transport/error_mapping.py +102 -0
- transcodely/_transport/headers.py +31 -0
- transcodely/_transport/transport.py +312 -0
- transcodely/client.py +160 -0
- transcodely/errors.py +115 -0
- transcodely/pagination.py +53 -0
- transcodely/py.typed +0 -0
- transcodely/resources/__init__.py +0 -0
- transcodely/resources/_helpers.py +29 -0
- transcodely/resources/api_keys.py +48 -0
- transcodely/resources/apps.py +59 -0
- transcodely/resources/events.py +118 -0
- transcodely/resources/health.py +19 -0
- transcodely/resources/jobs.py +120 -0
- transcodely/resources/memberships.py +54 -0
- transcodely/resources/organizations.py +73 -0
- transcodely/resources/origins.py +55 -0
- transcodely/resources/presets.py +63 -0
- transcodely/resources/users.py +46 -0
- transcodely/resources/videos.py +114 -0
- transcodely/resources/webhook_endpoints.py +242 -0
- transcodely/streaming.py +47 -0
- transcodely/types.py +570 -0
- transcodely/v1/api_key_pb2.py +69 -0
- transcodely/v1/api_key_pb2.pyi +97 -0
- transcodely/v1/app_pb2.py +107 -0
- transcodely/v1/app_pb2.pyi +219 -0
- transcodely/v1/codec_av1_pb2.py +55 -0
- transcodely/v1/codec_av1_pb2.pyi +34 -0
- transcodely/v1/codec_h264_pb2.py +71 -0
- transcodely/v1/codec_h264_pb2.pyi +44 -0
- transcodely/v1/codec_h265_pb2.py +69 -0
- transcodely/v1/codec_h265_pb2.pyi +42 -0
- transcodely/v1/codec_vp9_pb2.py +57 -0
- transcodely/v1/codec_vp9_pb2.pyi +30 -0
- transcodely/v1/common_pb2.py +67 -0
- transcodely/v1/common_pb2.pyi +171 -0
- transcodely/v1/content_aware_pb2.py +56 -0
- transcodely/v1/content_aware_pb2.pyi +51 -0
- transcodely/v1/drm_pb2.py +65 -0
- transcodely/v1/drm_pb2.pyi +68 -0
- transcodely/v1/hdr_pb2.py +57 -0
- transcodely/v1/hdr_pb2.pyi +64 -0
- transcodely/v1/health_pb2.py +44 -0
- transcodely/v1/health_pb2.pyi +44 -0
- transcodely/v1/job_pb2.py +201 -0
- transcodely/v1/job_pb2.pyi +546 -0
- transcodely/v1/media_pb2.py +43 -0
- transcodely/v1/media_pb2.pyi +100 -0
- transcodely/v1/membership_pb2.py +71 -0
- transcodely/v1/membership_pb2.pyi +122 -0
- transcodely/v1/organization_pb2.py +81 -0
- transcodely/v1/organization_pb2.pyi +121 -0
- transcodely/v1/origin_pb2.py +157 -0
- transcodely/v1/origin_pb2.pyi +317 -0
- transcodely/v1/preset_pb2.py +192 -0
- transcodely/v1/preset_pb2.pyi +290 -0
- transcodely/v1/streaming_pb2.py +59 -0
- transcodely/v1/streaming_pb2.pyi +56 -0
- transcodely/v1/subtitles_pb2.py +69 -0
- transcodely/v1/subtitles_pb2.pyi +75 -0
- transcodely/v1/thumbnails_pb2.py +63 -0
- transcodely/v1/thumbnails_pb2.pyi +74 -0
- transcodely/v1/user_pb2.py +72 -0
- transcodely/v1/user_pb2.pyi +137 -0
- transcodely/v1/video_pb2.py +166 -0
- transcodely/v1/video_pb2.pyi +367 -0
- transcodely/v1/webhook_pb2.py +151 -0
- transcodely/v1/webhook_pb2.pyi +336 -0
- transcodely/version.py +11 -0
- transcodely/webhooks/__init__.py +44 -0
- transcodely/webhooks/construct_event.py +111 -0
- transcodely/webhooks/signature.py +110 -0
- transcodely/webhooks/types.py +115 -0
- transcodely-0.2.0.dist-info/METADATA +349 -0
- transcodely-0.2.0.dist-info/RECORD +86 -0
- transcodely-0.2.0.dist-info/WHEEL +4 -0
- transcodely-0.2.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""API key resource."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Optional
|
|
6
|
+
|
|
7
|
+
from .._transport.transport import CallOptions, Transport
|
|
8
|
+
from ..pagination import Page, PageContents
|
|
9
|
+
from ..v1 import api_key_pb2
|
|
10
|
+
from ._helpers import assign_pagination, fill_from_dict
|
|
11
|
+
|
|
12
|
+
_SERVICE = "transcodely.v1.APIKeyService"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ApiKeys:
|
|
16
|
+
def __init__(self, transport: Transport) -> None:
|
|
17
|
+
self._t = transport
|
|
18
|
+
|
|
19
|
+
def create(self, **kwargs: Any) -> api_key_pb2.CreateAPIKeyResponse:
|
|
20
|
+
"""Create a new key. The full secret is only present on this response — store it safely."""
|
|
21
|
+
req = fill_from_dict(api_key_pb2.CreateAPIKeyRequest(), kwargs)
|
|
22
|
+
return self._t.unary(_SERVICE, "Create", req, api_key_pb2.CreateAPIKeyResponse())
|
|
23
|
+
|
|
24
|
+
def get(self, id: str, opts: Optional[CallOptions] = None) -> api_key_pb2.APIKey:
|
|
25
|
+
req = api_key_pb2.GetAPIKeyRequest(id=id)
|
|
26
|
+
return self._t.unary(_SERVICE, "Get", req, api_key_pb2.GetAPIKeyResponse(), opts).api_key
|
|
27
|
+
|
|
28
|
+
def list(
|
|
29
|
+
self,
|
|
30
|
+
*,
|
|
31
|
+
limit: Optional[int] = None,
|
|
32
|
+
opts: Optional[CallOptions] = None,
|
|
33
|
+
) -> Page[api_key_pb2.APIKey]:
|
|
34
|
+
def fetch(cursor: Optional[str]) -> PageContents[api_key_pb2.APIKey]:
|
|
35
|
+
req = api_key_pb2.ListAPIKeysRequest()
|
|
36
|
+
assign_pagination(req.pagination, limit=limit, cursor=cursor)
|
|
37
|
+
res = self._t.unary(_SERVICE, "List", req, api_key_pb2.ListAPIKeysResponse(), opts)
|
|
38
|
+
return PageContents(
|
|
39
|
+
items=list(res.api_keys), next_cursor=res.pagination.next_cursor or None
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
return Page(fetch)
|
|
43
|
+
|
|
44
|
+
def revoke(self, id: str, opts: Optional[CallOptions] = None) -> api_key_pb2.APIKey:
|
|
45
|
+
req = api_key_pb2.RevokeAPIKeyRequest(id=id)
|
|
46
|
+
return self._t.unary(
|
|
47
|
+
_SERVICE, "Revoke", req, api_key_pb2.RevokeAPIKeyResponse(), opts
|
|
48
|
+
).api_key
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""App resource."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Optional
|
|
6
|
+
|
|
7
|
+
from .._transport.transport import CallOptions, Transport
|
|
8
|
+
from ..pagination import Page, PageContents
|
|
9
|
+
from ..v1 import app_pb2
|
|
10
|
+
from ._helpers import assign_pagination, fill_from_dict
|
|
11
|
+
|
|
12
|
+
_SERVICE = "transcodely.v1.AppService"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Apps:
|
|
16
|
+
def __init__(self, transport: Transport) -> None:
|
|
17
|
+
self._t = transport
|
|
18
|
+
|
|
19
|
+
def create(self, **kwargs: Any) -> app_pb2.App:
|
|
20
|
+
req = fill_from_dict(app_pb2.CreateAppRequest(), kwargs)
|
|
21
|
+
return self._t.unary(_SERVICE, "Create", req, app_pb2.CreateAppResponse()).app
|
|
22
|
+
|
|
23
|
+
def get(self, id: str, opts: Optional[CallOptions] = None) -> app_pb2.App:
|
|
24
|
+
req = app_pb2.GetAppRequest(id=id)
|
|
25
|
+
return self._t.unary(_SERVICE, "Get", req, app_pb2.GetAppResponse(), opts).app
|
|
26
|
+
|
|
27
|
+
def update(self, **kwargs: Any) -> app_pb2.App:
|
|
28
|
+
req = fill_from_dict(app_pb2.UpdateAppRequest(), kwargs)
|
|
29
|
+
return self._t.unary(_SERVICE, "Update", req, app_pb2.UpdateAppResponse()).app
|
|
30
|
+
|
|
31
|
+
def list(
|
|
32
|
+
self,
|
|
33
|
+
*,
|
|
34
|
+
limit: Optional[int] = None,
|
|
35
|
+
opts: Optional[CallOptions] = None,
|
|
36
|
+
) -> Page[app_pb2.App]:
|
|
37
|
+
def fetch(cursor: Optional[str]) -> PageContents[app_pb2.App]:
|
|
38
|
+
req = app_pb2.ListAppsRequest()
|
|
39
|
+
assign_pagination(req.pagination, limit=limit, cursor=cursor)
|
|
40
|
+
res = self._t.unary(_SERVICE, "List", req, app_pb2.ListAppsResponse(), opts)
|
|
41
|
+
return PageContents(
|
|
42
|
+
items=list(res.apps), next_cursor=res.pagination.next_cursor or None
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
return Page(fetch)
|
|
46
|
+
|
|
47
|
+
def archive(self, id: str, opts: Optional[CallOptions] = None) -> app_pb2.App:
|
|
48
|
+
req = app_pb2.ArchiveAppRequest(id=id)
|
|
49
|
+
return self._t.unary(_SERVICE, "Archive", req, app_pb2.ArchiveAppResponse(), opts).app
|
|
50
|
+
|
|
51
|
+
def enable_hosting(self, **kwargs: Any) -> app_pb2.EnableHostingResponse:
|
|
52
|
+
req = fill_from_dict(app_pb2.EnableHostingRequest(), kwargs)
|
|
53
|
+
return self._t.unary(_SERVICE, "EnableHosting", req, app_pb2.EnableHostingResponse())
|
|
54
|
+
|
|
55
|
+
def update_hosting_config(self, **kwargs: Any) -> app_pb2.UpdateHostingConfigResponse:
|
|
56
|
+
req = fill_from_dict(app_pb2.UpdateHostingConfigRequest(), kwargs)
|
|
57
|
+
return self._t.unary(
|
|
58
|
+
_SERVICE, "UpdateHostingConfig", req, app_pb2.UpdateHostingConfigResponse()
|
|
59
|
+
)
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"""Event resource — query and replay events.
|
|
2
|
+
|
|
3
|
+
Every event handed back is the same unified :class:`~transcodely.webhooks.types.Event`
|
|
4
|
+
that :func:`transcodely.construct_event` produces, so a ``job.succeeded`` handler
|
|
5
|
+
can be exercised against an event pulled from :meth:`Events.retrieve` and behave
|
|
6
|
+
identically. The bridge from the proto-shape ``Event`` (which carries the inner
|
|
7
|
+
resource as a JSON string) to the SDK-shape :class:`Event` is
|
|
8
|
+
:func:`proto_event_to_sdk`.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import json
|
|
14
|
+
from datetime import datetime
|
|
15
|
+
from typing import Any, Optional
|
|
16
|
+
|
|
17
|
+
from .._transport.transport import CallOptions, Transport
|
|
18
|
+
from ..pagination import Page, PageContents
|
|
19
|
+
from ..v1 import common_pb2, webhook_pb2
|
|
20
|
+
from ..webhooks.types import Event, EventRequest, decoder_for_type
|
|
21
|
+
|
|
22
|
+
_SERVICE = "transcodely.v1.WebhookService"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class Events:
|
|
26
|
+
def __init__(self, transport: Transport) -> None:
|
|
27
|
+
self._t = transport
|
|
28
|
+
|
|
29
|
+
def retrieve(self, id: str, opts: Optional[CallOptions] = None) -> Event:
|
|
30
|
+
req = webhook_pb2.RetrieveEventRequest(id=id)
|
|
31
|
+
res = self._t.unary(
|
|
32
|
+
_SERVICE, "RetrieveEvent", req, webhook_pb2.RetrieveEventResponse(), opts
|
|
33
|
+
)
|
|
34
|
+
return proto_event_to_sdk(res.event)
|
|
35
|
+
|
|
36
|
+
def resend(
|
|
37
|
+
self,
|
|
38
|
+
id: str,
|
|
39
|
+
*,
|
|
40
|
+
endpoint_ids: Optional[list[str]] = None,
|
|
41
|
+
opts: Optional[CallOptions] = None,
|
|
42
|
+
) -> list[webhook_pb2.WebhookDelivery]:
|
|
43
|
+
"""Resend an existing event, creating new pending delivery records — one
|
|
44
|
+
per target endpoint. When ``endpoint_ids`` is omitted, resends to every
|
|
45
|
+
currently-subscribed enabled endpoint."""
|
|
46
|
+
req = webhook_pb2.ResendEventRequest(id=id)
|
|
47
|
+
if endpoint_ids:
|
|
48
|
+
req.endpoint_ids.extend(endpoint_ids)
|
|
49
|
+
res = self._t.unary(_SERVICE, "ResendEvent", req, webhook_pb2.ResendEventResponse(), opts)
|
|
50
|
+
return list(res.deliveries)
|
|
51
|
+
|
|
52
|
+
def list(
|
|
53
|
+
self,
|
|
54
|
+
*,
|
|
55
|
+
app_id: str,
|
|
56
|
+
type: Optional[str] = None,
|
|
57
|
+
created_after: Optional[datetime] = None,
|
|
58
|
+
created_before: Optional[datetime] = None,
|
|
59
|
+
limit: Optional[int] = None,
|
|
60
|
+
opts: Optional[CallOptions] = None,
|
|
61
|
+
) -> Page[Event]:
|
|
62
|
+
def fetch(cursor: Optional[str]) -> PageContents[Event]:
|
|
63
|
+
req = webhook_pb2.ListEventsRequest(app_id=app_id)
|
|
64
|
+
if type is not None:
|
|
65
|
+
req.type = type
|
|
66
|
+
if created_after is not None:
|
|
67
|
+
req.created_after.FromDatetime(created_after)
|
|
68
|
+
if created_before is not None:
|
|
69
|
+
req.created_before.FromDatetime(created_before)
|
|
70
|
+
pagination = common_pb2.PaginationRequest()
|
|
71
|
+
if limit is not None:
|
|
72
|
+
pagination.limit = limit
|
|
73
|
+
if cursor is not None:
|
|
74
|
+
pagination.cursor = cursor
|
|
75
|
+
req.pagination.CopyFrom(pagination)
|
|
76
|
+
res = self._t.unary(_SERVICE, "ListEvents", req, webhook_pb2.ListEventsResponse(), opts)
|
|
77
|
+
return PageContents(
|
|
78
|
+
items=[proto_event_to_sdk(e) for e in res.events],
|
|
79
|
+
next_cursor=res.pagination.next_cursor or None,
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
return Page(fetch)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def proto_event_to_sdk(proto: webhook_pb2.Event) -> Event:
|
|
86
|
+
"""Bridge a proto ``Event`` (``data`` as a JSON string, ``created_at`` as a
|
|
87
|
+
``Timestamp``) to the SDK :class:`Event` (decoded resource, RFC 3339 string).
|
|
88
|
+
|
|
89
|
+
Used by :meth:`Events.retrieve` and :meth:`Events.list`.
|
|
90
|
+
"""
|
|
91
|
+
parsed_data: Any = {}
|
|
92
|
+
if proto.data:
|
|
93
|
+
try:
|
|
94
|
+
parsed_data = json.loads(proto.data)
|
|
95
|
+
except ValueError:
|
|
96
|
+
# Server-controlled; if it ever fails, leave the placeholder so the
|
|
97
|
+
# event still surfaces.
|
|
98
|
+
pass
|
|
99
|
+
|
|
100
|
+
decode = decoder_for_type(proto.type)
|
|
101
|
+
data: Any = decode(parsed_data) if decode and isinstance(parsed_data, dict) else parsed_data
|
|
102
|
+
|
|
103
|
+
created = proto.created_at.ToJsonString() if proto.HasField("created_at") else ""
|
|
104
|
+
|
|
105
|
+
return Event(
|
|
106
|
+
id=proto.id,
|
|
107
|
+
object="event",
|
|
108
|
+
api_version=proto.api_version,
|
|
109
|
+
created=created,
|
|
110
|
+
type=proto.type,
|
|
111
|
+
data=data,
|
|
112
|
+
pending_webhooks=proto.pending_webhooks,
|
|
113
|
+
# proto Event carries only request_id; idempotency_key is always None
|
|
114
|
+
# until JobService.Create propagates it. An unset request_id maps to
|
|
115
|
+
# None so this path matches the webhook envelope path (both use None for
|
|
116
|
+
# events emitted outside a request scope).
|
|
117
|
+
request=EventRequest(id=proto.request_id or None, idempotency_key=None),
|
|
118
|
+
)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Health resource — liveness check for the API."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Optional
|
|
6
|
+
|
|
7
|
+
from .._transport.transport import CallOptions, Transport
|
|
8
|
+
from ..v1 import health_pb2
|
|
9
|
+
|
|
10
|
+
_SERVICE = "transcodely.v1.HealthService"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Health:
|
|
14
|
+
def __init__(self, transport: Transport) -> None:
|
|
15
|
+
self._t = transport
|
|
16
|
+
|
|
17
|
+
def check(self, opts: Optional[CallOptions] = None) -> health_pb2.HealthCheckResponse:
|
|
18
|
+
req = health_pb2.HealthCheckRequest()
|
|
19
|
+
return self._t.unary(_SERVICE, "Check", req, health_pb2.HealthCheckResponse(), opts)
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"""Job resource — create / get / list / cancel / confirm / watch."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Generator, Mapping, Optional
|
|
6
|
+
|
|
7
|
+
from .._transport.transport import CallOptions, Transport
|
|
8
|
+
from ..pagination import Page, PageContents
|
|
9
|
+
from ..streaming import watch
|
|
10
|
+
from ..v1 import job_pb2
|
|
11
|
+
|
|
12
|
+
_SERVICE = "transcodely.v1.JobService"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Jobs:
|
|
16
|
+
def __init__(self, transport: Transport) -> None:
|
|
17
|
+
self._t = transport
|
|
18
|
+
|
|
19
|
+
def create(
|
|
20
|
+
self,
|
|
21
|
+
input_url: Optional[str] = None,
|
|
22
|
+
outputs: Optional[list[Mapping[str, Any]]] = None,
|
|
23
|
+
*,
|
|
24
|
+
idempotency_key: Optional[str] = None,
|
|
25
|
+
webhook_url: Optional[str] = None,
|
|
26
|
+
priority: Optional[int] = None,
|
|
27
|
+
metadata: Optional[Mapping[str, str]] = None,
|
|
28
|
+
request: Optional[job_pb2.CreateJobRequest] = None,
|
|
29
|
+
opts: Optional[CallOptions] = None,
|
|
30
|
+
) -> job_pb2.Job:
|
|
31
|
+
"""Create a new transcoding job. Auto-fills ``idempotency_key`` if omitted."""
|
|
32
|
+
if request is None:
|
|
33
|
+
req = job_pb2.CreateJobRequest()
|
|
34
|
+
if input_url is not None:
|
|
35
|
+
req.input_url = input_url
|
|
36
|
+
if outputs:
|
|
37
|
+
from google.protobuf import json_format
|
|
38
|
+
|
|
39
|
+
from .._codec.json_codec import transform_enums_in_dict
|
|
40
|
+
|
|
41
|
+
# Outputs are nested messages — round-trip through JSON so callers can
|
|
42
|
+
# pass plain dicts with simplified-enum strings.
|
|
43
|
+
payload = {"outputs": list(outputs)}
|
|
44
|
+
transform_enums_in_dict(payload, req.DESCRIPTOR, mode="expand")
|
|
45
|
+
json_format.ParseDict(payload, req, ignore_unknown_fields=True)
|
|
46
|
+
if webhook_url is not None:
|
|
47
|
+
req.webhook_url = webhook_url
|
|
48
|
+
if priority is not None:
|
|
49
|
+
req.priority = priority
|
|
50
|
+
if metadata:
|
|
51
|
+
for k, v in metadata.items():
|
|
52
|
+
req.metadata[k] = v
|
|
53
|
+
else:
|
|
54
|
+
req = request
|
|
55
|
+
if not req.idempotency_key:
|
|
56
|
+
from .._transport.headers import new_idempotency_key
|
|
57
|
+
|
|
58
|
+
req.idempotency_key = idempotency_key or new_idempotency_key()
|
|
59
|
+
res = self._t.unary(_SERVICE, "Create", req, job_pb2.CreateJobResponse(), opts)
|
|
60
|
+
return res.job
|
|
61
|
+
|
|
62
|
+
def get(self, id: str, opts: Optional[CallOptions] = None) -> job_pb2.Job:
|
|
63
|
+
req = job_pb2.GetJobRequest(id=id)
|
|
64
|
+
return self._t.unary(_SERVICE, "Get", req, job_pb2.GetJobResponse(), opts).job
|
|
65
|
+
|
|
66
|
+
def list(
|
|
67
|
+
self,
|
|
68
|
+
*,
|
|
69
|
+
status: Optional[int] = None,
|
|
70
|
+
limit: Optional[int] = None,
|
|
71
|
+
opts: Optional[CallOptions] = None,
|
|
72
|
+
) -> Page[job_pb2.Job]:
|
|
73
|
+
from ..v1 import common_pb2
|
|
74
|
+
|
|
75
|
+
def fetch(cursor: Optional[str]) -> PageContents[job_pb2.Job]:
|
|
76
|
+
req = job_pb2.ListJobsRequest()
|
|
77
|
+
if status is not None:
|
|
78
|
+
req.status = status
|
|
79
|
+
pagination = common_pb2.PaginationRequest()
|
|
80
|
+
if limit is not None:
|
|
81
|
+
pagination.limit = limit
|
|
82
|
+
if cursor is not None:
|
|
83
|
+
pagination.cursor = cursor
|
|
84
|
+
req.pagination.CopyFrom(pagination)
|
|
85
|
+
res = self._t.unary(_SERVICE, "List", req, job_pb2.ListJobsResponse(), opts)
|
|
86
|
+
return PageContents(
|
|
87
|
+
items=list(res.jobs),
|
|
88
|
+
next_cursor=res.pagination.next_cursor or None,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
return Page(fetch)
|
|
92
|
+
|
|
93
|
+
def cancel(self, id: str, opts: Optional[CallOptions] = None) -> job_pb2.Job:
|
|
94
|
+
req = job_pb2.CancelJobRequest(id=id)
|
|
95
|
+
return self._t.unary(_SERVICE, "Cancel", req, job_pb2.CancelJobResponse(), opts).job
|
|
96
|
+
|
|
97
|
+
def confirm(self, id: str, opts: Optional[CallOptions] = None) -> job_pb2.Job:
|
|
98
|
+
req = job_pb2.ConfirmJobRequest(id=id)
|
|
99
|
+
return self._t.unary(_SERVICE, "Confirm", req, job_pb2.ConfirmJobResponse(), opts).job
|
|
100
|
+
|
|
101
|
+
def watch(
|
|
102
|
+
self,
|
|
103
|
+
id: str,
|
|
104
|
+
*,
|
|
105
|
+
include_heartbeats: bool = False,
|
|
106
|
+
max_reconnects: int = 5,
|
|
107
|
+
opts: Optional[CallOptions] = None,
|
|
108
|
+
) -> Generator[job_pb2.WatchJobResponse, None, None]:
|
|
109
|
+
"""Stream live job state. Auto-reconnects + filters HEARTBEAT events by default."""
|
|
110
|
+
|
|
111
|
+
def factory() -> Generator[job_pb2.WatchJobResponse, None, None]:
|
|
112
|
+
req = job_pb2.WatchJobRequest(id=id)
|
|
113
|
+
yield from self._t.stream(_SERVICE, "Watch", req, job_pb2.WatchJobResponse, opts)
|
|
114
|
+
|
|
115
|
+
yield from watch(
|
|
116
|
+
factory,
|
|
117
|
+
is_heartbeat=lambda e: e.event == job_pb2.WATCH_EVENT_TYPE_HEARTBEAT,
|
|
118
|
+
include_heartbeats=include_heartbeats,
|
|
119
|
+
max_reconnects=max_reconnects,
|
|
120
|
+
)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""Membership resource."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Optional
|
|
6
|
+
|
|
7
|
+
from .._transport.transport import CallOptions, Transport
|
|
8
|
+
from ..pagination import Page, PageContents
|
|
9
|
+
from ..v1 import membership_pb2
|
|
10
|
+
from ._helpers import assign_pagination, fill_from_dict
|
|
11
|
+
|
|
12
|
+
_SERVICE = "transcodely.v1.MembershipService"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Memberships:
|
|
16
|
+
def __init__(self, transport: Transport) -> None:
|
|
17
|
+
self._t = transport
|
|
18
|
+
|
|
19
|
+
def list(
|
|
20
|
+
self,
|
|
21
|
+
*,
|
|
22
|
+
limit: Optional[int] = None,
|
|
23
|
+
opts: Optional[CallOptions] = None,
|
|
24
|
+
) -> Page[membership_pb2.MembershipWithUser]:
|
|
25
|
+
def fetch(cursor: Optional[str]) -> PageContents[membership_pb2.MembershipWithUser]:
|
|
26
|
+
req = membership_pb2.ListMembershipsRequest()
|
|
27
|
+
assign_pagination(req.pagination, limit=limit, cursor=cursor)
|
|
28
|
+
res = self._t.unary(
|
|
29
|
+
_SERVICE, "List", req, membership_pb2.ListMembershipsResponse(), opts
|
|
30
|
+
)
|
|
31
|
+
return PageContents(
|
|
32
|
+
items=list(res.memberships), next_cursor=res.pagination.next_cursor or None
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
return Page(fetch)
|
|
36
|
+
|
|
37
|
+
def get(self, id: str, opts: Optional[CallOptions] = None) -> membership_pb2.MembershipWithUser:
|
|
38
|
+
req = membership_pb2.GetMembershipRequest(id=id)
|
|
39
|
+
return self._t.unary(
|
|
40
|
+
_SERVICE, "Get", req, membership_pb2.GetMembershipResponse(), opts
|
|
41
|
+
).membership
|
|
42
|
+
|
|
43
|
+
def update_role(self, **kwargs: Any) -> membership_pb2.Membership:
|
|
44
|
+
req = fill_from_dict(membership_pb2.UpdateMembershipRoleRequest(), kwargs)
|
|
45
|
+
return self._t.unary(
|
|
46
|
+
_SERVICE,
|
|
47
|
+
"UpdateRole",
|
|
48
|
+
req,
|
|
49
|
+
membership_pb2.UpdateMembershipRoleResponse(),
|
|
50
|
+
).membership
|
|
51
|
+
|
|
52
|
+
def remove(self, id: str, opts: Optional[CallOptions] = None) -> None:
|
|
53
|
+
req = membership_pb2.RemoveMembershipRequest(id=id)
|
|
54
|
+
self._t.unary(_SERVICE, "Remove", req, membership_pb2.RemoveMembershipResponse(), opts)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""Organization resource."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Optional
|
|
6
|
+
|
|
7
|
+
from .._transport.transport import CallOptions, Transport
|
|
8
|
+
from ..pagination import Page, PageContents
|
|
9
|
+
from ..v1 import organization_pb2
|
|
10
|
+
from ._helpers import assign_pagination, fill_from_dict
|
|
11
|
+
|
|
12
|
+
_SERVICE = "transcodely.v1.OrganizationService"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Organizations:
|
|
16
|
+
def __init__(self, transport: Transport) -> None:
|
|
17
|
+
self._t = transport
|
|
18
|
+
|
|
19
|
+
def check_slug(
|
|
20
|
+
self, slug: str, opts: Optional[CallOptions] = None
|
|
21
|
+
) -> organization_pb2.CheckSlugResponse:
|
|
22
|
+
req = organization_pb2.CheckSlugRequest(slug=slug)
|
|
23
|
+
return self._t.unary(_SERVICE, "CheckSlug", req, organization_pb2.CheckSlugResponse(), opts)
|
|
24
|
+
|
|
25
|
+
def create(self, **kwargs: Any) -> organization_pb2.Organization:
|
|
26
|
+
req = fill_from_dict(organization_pb2.CreateOrganizationRequest(), kwargs)
|
|
27
|
+
return self._t.unary(
|
|
28
|
+
_SERVICE,
|
|
29
|
+
"Create",
|
|
30
|
+
req,
|
|
31
|
+
organization_pb2.CreateOrganizationResponse(),
|
|
32
|
+
).organization
|
|
33
|
+
|
|
34
|
+
def get(
|
|
35
|
+
self, id_or_slug: str, opts: Optional[CallOptions] = None
|
|
36
|
+
) -> organization_pb2.Organization:
|
|
37
|
+
"""Look up by ID (``org_*``) or slug."""
|
|
38
|
+
req = organization_pb2.GetOrganizationRequest(id_or_slug=id_or_slug)
|
|
39
|
+
return self._t.unary(
|
|
40
|
+
_SERVICE,
|
|
41
|
+
"Get",
|
|
42
|
+
req,
|
|
43
|
+
organization_pb2.GetOrganizationResponse(),
|
|
44
|
+
opts,
|
|
45
|
+
).organization
|
|
46
|
+
|
|
47
|
+
def update(self, **kwargs: Any) -> organization_pb2.Organization:
|
|
48
|
+
req = fill_from_dict(organization_pb2.UpdateOrganizationRequest(), kwargs)
|
|
49
|
+
return self._t.unary(
|
|
50
|
+
_SERVICE,
|
|
51
|
+
"Update",
|
|
52
|
+
req,
|
|
53
|
+
organization_pb2.UpdateOrganizationResponse(),
|
|
54
|
+
).organization
|
|
55
|
+
|
|
56
|
+
def list(
|
|
57
|
+
self,
|
|
58
|
+
*,
|
|
59
|
+
limit: Optional[int] = None,
|
|
60
|
+
opts: Optional[CallOptions] = None,
|
|
61
|
+
) -> Page[organization_pb2.Organization]:
|
|
62
|
+
def fetch(cursor: Optional[str]) -> PageContents[organization_pb2.Organization]:
|
|
63
|
+
req = organization_pb2.ListOrganizationsRequest()
|
|
64
|
+
assign_pagination(req.pagination, limit=limit, cursor=cursor)
|
|
65
|
+
res = self._t.unary(
|
|
66
|
+
_SERVICE, "List", req, organization_pb2.ListOrganizationsResponse(), opts
|
|
67
|
+
)
|
|
68
|
+
return PageContents(
|
|
69
|
+
items=list(res.organizations),
|
|
70
|
+
next_cursor=res.pagination.next_cursor or None,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
return Page(fetch)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""Origin resource — input/output storage destinations."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Optional
|
|
6
|
+
|
|
7
|
+
from .._transport.transport import CallOptions, Transport
|
|
8
|
+
from ..pagination import Page, PageContents
|
|
9
|
+
from ..v1 import origin_pb2
|
|
10
|
+
from ._helpers import assign_pagination, fill_from_dict
|
|
11
|
+
|
|
12
|
+
_SERVICE = "transcodely.v1.OriginService"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Origins:
|
|
16
|
+
def __init__(self, transport: Transport) -> None:
|
|
17
|
+
self._t = transport
|
|
18
|
+
|
|
19
|
+
def create(self, **kwargs: Any) -> origin_pb2.Origin:
|
|
20
|
+
req = fill_from_dict(origin_pb2.CreateOriginRequest(), kwargs)
|
|
21
|
+
return self._t.unary(_SERVICE, "Create", req, origin_pb2.CreateOriginResponse()).origin
|
|
22
|
+
|
|
23
|
+
def get(self, id: str, opts: Optional[CallOptions] = None) -> origin_pb2.Origin:
|
|
24
|
+
req = origin_pb2.GetOriginRequest(id=id)
|
|
25
|
+
return self._t.unary(_SERVICE, "Get", req, origin_pb2.GetOriginResponse(), opts).origin
|
|
26
|
+
|
|
27
|
+
def list(
|
|
28
|
+
self,
|
|
29
|
+
*,
|
|
30
|
+
limit: Optional[int] = None,
|
|
31
|
+
opts: Optional[CallOptions] = None,
|
|
32
|
+
) -> Page[origin_pb2.Origin]:
|
|
33
|
+
def fetch(cursor: Optional[str]) -> PageContents[origin_pb2.Origin]:
|
|
34
|
+
req = origin_pb2.ListOriginsRequest()
|
|
35
|
+
assign_pagination(req.pagination, limit=limit, cursor=cursor)
|
|
36
|
+
res = self._t.unary(_SERVICE, "List", req, origin_pb2.ListOriginsResponse(), opts)
|
|
37
|
+
return PageContents(
|
|
38
|
+
items=list(res.origins), next_cursor=res.pagination.next_cursor or None
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
return Page(fetch)
|
|
42
|
+
|
|
43
|
+
def update(self, **kwargs: Any) -> origin_pb2.Origin:
|
|
44
|
+
req = fill_from_dict(origin_pb2.UpdateOriginRequest(), kwargs)
|
|
45
|
+
return self._t.unary(_SERVICE, "Update", req, origin_pb2.UpdateOriginResponse()).origin
|
|
46
|
+
|
|
47
|
+
def validate(self, **kwargs: Any) -> origin_pb2.ValidateOriginResponse:
|
|
48
|
+
req = fill_from_dict(origin_pb2.ValidateOriginRequest(), kwargs)
|
|
49
|
+
return self._t.unary(_SERVICE, "Validate", req, origin_pb2.ValidateOriginResponse())
|
|
50
|
+
|
|
51
|
+
def archive(self, id: str, opts: Optional[CallOptions] = None) -> origin_pb2.Origin:
|
|
52
|
+
req = origin_pb2.ArchiveOriginRequest(id=id)
|
|
53
|
+
return self._t.unary(
|
|
54
|
+
_SERVICE, "Archive", req, origin_pb2.ArchiveOriginResponse(), opts
|
|
55
|
+
).origin
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""Preset resource."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Optional
|
|
6
|
+
|
|
7
|
+
from .._transport.transport import CallOptions, Transport
|
|
8
|
+
from ..pagination import Page, PageContents
|
|
9
|
+
from ..v1 import preset_pb2
|
|
10
|
+
from ._helpers import assign_pagination, fill_from_dict
|
|
11
|
+
|
|
12
|
+
_SERVICE = "transcodely.v1.PresetService"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Presets:
|
|
16
|
+
def __init__(self, transport: Transport) -> None:
|
|
17
|
+
self._t = transport
|
|
18
|
+
|
|
19
|
+
def create(self, **kwargs: Any) -> preset_pb2.Preset:
|
|
20
|
+
req = fill_from_dict(preset_pb2.CreatePresetRequest(), kwargs)
|
|
21
|
+
return self._t.unary(_SERVICE, "Create", req, preset_pb2.CreatePresetResponse()).preset
|
|
22
|
+
|
|
23
|
+
def get(self, id: str, opts: Optional[CallOptions] = None) -> preset_pb2.Preset:
|
|
24
|
+
req = preset_pb2.GetPresetRequest(id=id)
|
|
25
|
+
return self._t.unary(_SERVICE, "Get", req, preset_pb2.GetPresetResponse(), opts).preset
|
|
26
|
+
|
|
27
|
+
def get_by_slug(self, slug: str, opts: Optional[CallOptions] = None) -> preset_pb2.Preset:
|
|
28
|
+
req = preset_pb2.GetPresetBySlugRequest(slug=slug)
|
|
29
|
+
return self._t.unary(
|
|
30
|
+
_SERVICE, "GetBySlug", req, preset_pb2.GetPresetBySlugResponse(), opts
|
|
31
|
+
).preset
|
|
32
|
+
|
|
33
|
+
def list(
|
|
34
|
+
self,
|
|
35
|
+
*,
|
|
36
|
+
limit: Optional[int] = None,
|
|
37
|
+
opts: Optional[CallOptions] = None,
|
|
38
|
+
) -> Page[preset_pb2.Preset]:
|
|
39
|
+
def fetch(cursor: Optional[str]) -> PageContents[preset_pb2.Preset]:
|
|
40
|
+
req = preset_pb2.ListPresetsRequest()
|
|
41
|
+
assign_pagination(req.pagination, limit=limit, cursor=cursor)
|
|
42
|
+
res = self._t.unary(_SERVICE, "List", req, preset_pb2.ListPresetsResponse(), opts)
|
|
43
|
+
return PageContents(
|
|
44
|
+
items=list(res.presets), next_cursor=res.pagination.next_cursor or None
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
return Page(fetch)
|
|
48
|
+
|
|
49
|
+
def update(self, **kwargs: Any) -> preset_pb2.Preset:
|
|
50
|
+
req = fill_from_dict(preset_pb2.UpdatePresetRequest(), kwargs)
|
|
51
|
+
return self._t.unary(_SERVICE, "Update", req, preset_pb2.UpdatePresetResponse()).preset
|
|
52
|
+
|
|
53
|
+
def duplicate(self, **kwargs: Any) -> preset_pb2.Preset:
|
|
54
|
+
req = fill_from_dict(preset_pb2.DuplicatePresetRequest(), kwargs)
|
|
55
|
+
return self._t.unary(
|
|
56
|
+
_SERVICE, "Duplicate", req, preset_pb2.DuplicatePresetResponse()
|
|
57
|
+
).preset
|
|
58
|
+
|
|
59
|
+
def archive(self, id: str, opts: Optional[CallOptions] = None) -> preset_pb2.Preset:
|
|
60
|
+
req = preset_pb2.ArchivePresetRequest(id=id)
|
|
61
|
+
return self._t.unary(
|
|
62
|
+
_SERVICE, "Archive", req, preset_pb2.ArchivePresetResponse(), opts
|
|
63
|
+
).preset
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""User resource."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Optional
|
|
6
|
+
|
|
7
|
+
from .._transport.transport import CallOptions, Transport
|
|
8
|
+
from ..pagination import Page, PageContents
|
|
9
|
+
from ..v1 import user_pb2
|
|
10
|
+
from ._helpers import assign_pagination, fill_from_dict
|
|
11
|
+
|
|
12
|
+
_SERVICE = "transcodely.v1.UserService"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Users:
|
|
16
|
+
def __init__(self, transport: Transport) -> None:
|
|
17
|
+
self._t = transport
|
|
18
|
+
|
|
19
|
+
def get_me(self, opts: Optional[CallOptions] = None) -> user_pb2.UserWithOrganizations:
|
|
20
|
+
"""Returns the authenticated user enriched with org memberships."""
|
|
21
|
+
req = user_pb2.GetMeRequest()
|
|
22
|
+
return self._t.unary(_SERVICE, "GetMe", req, user_pb2.GetMeResponse(), opts).user
|
|
23
|
+
|
|
24
|
+
def update_me(self, **kwargs: Any) -> user_pb2.User:
|
|
25
|
+
req = fill_from_dict(user_pb2.UpdateMeRequest(), kwargs)
|
|
26
|
+
return self._t.unary(_SERVICE, "UpdateMe", req, user_pb2.UpdateMeResponse()).user
|
|
27
|
+
|
|
28
|
+
def get(self, id: str, opts: Optional[CallOptions] = None) -> user_pb2.User:
|
|
29
|
+
req = user_pb2.GetUserRequest(id=id)
|
|
30
|
+
return self._t.unary(_SERVICE, "Get", req, user_pb2.GetUserResponse(), opts).user
|
|
31
|
+
|
|
32
|
+
def list(
|
|
33
|
+
self,
|
|
34
|
+
*,
|
|
35
|
+
limit: Optional[int] = None,
|
|
36
|
+
opts: Optional[CallOptions] = None,
|
|
37
|
+
) -> Page[user_pb2.User]:
|
|
38
|
+
def fetch(cursor: Optional[str]) -> PageContents[user_pb2.User]:
|
|
39
|
+
req = user_pb2.ListUsersRequest()
|
|
40
|
+
assign_pagination(req.pagination, limit=limit, cursor=cursor)
|
|
41
|
+
res = self._t.unary(_SERVICE, "List", req, user_pb2.ListUsersResponse(), opts)
|
|
42
|
+
return PageContents(
|
|
43
|
+
items=list(res.users), next_cursor=res.pagination.next_cursor or None
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
return Page(fetch)
|