Skip to content

Commit

Permalink
RTMP broadcast endpoints (#47)
Browse files Browse the repository at this point in the history
* Update gen

* start rtmp list

* add new property to session response data

---------

Co-authored-by: Bruno Ribeiro <[email protected]>
  • Loading branch information
brunoribc and Bruno Ribeiro authored Sep 9, 2024
1 parent d19eb23 commit 377f142
Show file tree
Hide file tree
Showing 6 changed files with 1,723 additions and 339 deletions.
36 changes: 23 additions & 13 deletions getstream/chat/rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def query_channels(
offset: Optional[int] = None,
state: Optional[bool] = None,
user_id: Optional[str] = None,
sort: Optional[List[Optional[SortParam]]] = None,
sort: Optional[List[Optional[SortParamRequest]]] = None,
filter_conditions: Optional[Dict[str, object]] = None,
user: Optional[UserRequest] = None,
) -> StreamResponse[QueryChannelsResponse]:
Expand Down Expand Up @@ -203,7 +203,7 @@ def send_event(

def delete_file(
self, type: str, id: str, url: Optional[str] = None
) -> StreamResponse[FileDeleteResponse]:
) -> StreamResponse[Response]:
query_params = build_query_param(url=url)
path_params = {
"type": type,
Expand All @@ -212,7 +212,7 @@ def delete_file(

return self.delete(
"/api/v2/chat/channels/{type}/{id}/file",
FileDeleteResponse,
Response,
query_params=query_params,
path_params=path_params,
)
Expand Down Expand Up @@ -260,7 +260,7 @@ def hide_channel(

def delete_image(
self, type: str, id: str, url: Optional[str] = None
) -> StreamResponse[FileDeleteResponse]:
) -> StreamResponse[Response]:
query_params = build_query_param(url=url)
path_params = {
"type": type,
Expand All @@ -269,7 +269,7 @@ def delete_image(

return self.delete(
"/api/v2/chat/channels/{type}/{id}/image",
FileDeleteResponse,
Response,
query_params=query_params,
path_params=path_params,
)
Expand Down Expand Up @@ -492,6 +492,8 @@ def create_channel_type(
mark_messages_pending: Optional[bool] = None,
message_retention: Optional[str] = None,
mutes: Optional[bool] = None,
partition_size: Optional[int] = None,
partition_ttl: Optional[str] = None,
polls: Optional[bool] = None,
push_notifications: Optional[bool] = None,
reactions: Optional[bool] = None,
Expand All @@ -518,6 +520,8 @@ def create_channel_type(
mark_messages_pending=mark_messages_pending,
message_retention=message_retention,
mutes=mutes,
partition_size=partition_size,
partition_ttl=partition_ttl,
polls=polls,
push_notifications=push_notifications,
reactions=reactions,
Expand Down Expand Up @@ -546,13 +550,15 @@ def delete_channel_type(self, name: str) -> StreamResponse[Response]:
"/api/v2/chat/channeltypes/{name}", Response, path_params=path_params
)

def get_channel_type(self, name: str) -> StreamResponse[Response]:
def get_channel_type(self, name: str) -> StreamResponse[GetChannelTypeResponse]:
path_params = {
"name": name,
}

return self.get(
"/api/v2/chat/channeltypes/{name}", Response, path_params=path_params
"/api/v2/chat/channeltypes/{name}",
GetChannelTypeResponse,
path_params=path_params,
)

def update_channel_type(
Expand All @@ -567,6 +573,8 @@ def update_channel_type(
custom_events: Optional[bool] = None,
mark_messages_pending: Optional[bool] = None,
mutes: Optional[bool] = None,
partition_size: Optional[int] = None,
partition_ttl: Optional[str] = None,
polls: Optional[bool] = None,
push_notifications: Optional[bool] = None,
quotes: Optional[bool] = None,
Expand Down Expand Up @@ -598,6 +606,8 @@ def update_channel_type(
custom_events=custom_events,
mark_messages_pending=mark_messages_pending,
mutes=mutes,
partition_size=partition_size,
partition_ttl=partition_ttl,
polls=polls,
push_notifications=push_notifications,
quotes=quotes,
Expand Down Expand Up @@ -727,7 +737,7 @@ def query_message_history(
limit: Optional[int] = None,
next: Optional[str] = None,
prev: Optional[str] = None,
sort: Optional[List[Optional[SortParam]]] = None,
sort: Optional[List[Optional[SortParamRequest]]] = None,
) -> StreamResponse[QueryMessageHistoryResponse]:
json = build_body_dict(
filter=filter, limit=limit, next=next, prev=prev, sort=sort
Expand Down Expand Up @@ -903,7 +913,7 @@ def query_reactions(
next: Optional[str] = None,
prev: Optional[str] = None,
user_id: Optional[str] = None,
sort: Optional[List[Optional[SortParam]]] = None,
sort: Optional[List[Optional[SortParamRequest]]] = None,
filter: Optional[Dict[str, object]] = None,
user: Optional[UserRequest] = None,
) -> StreamResponse[QueryReactionsResponse]:
Expand Down Expand Up @@ -1010,7 +1020,7 @@ def get_replies(
created_at_before: Optional[datetime] = None,
id_around: Optional[str] = None,
created_at_around: Optional[datetime] = None,
sort: Optional[List[Optional[SortParam]]] = None,
sort: Optional[List[Optional[SortParamRequest]]] = None,
) -> StreamResponse[GetRepliesResponse]:
query_params = build_query_param(
limit=limit,
Expand Down Expand Up @@ -1125,7 +1135,7 @@ def update_poll(
max_votes_allowed: Optional[int] = None,
user_id: Optional[str] = None,
voting_visibility: Optional[str] = None,
options: Optional[List[Optional[PollOption]]] = None,
options: Optional[List[Optional[PollOptionRequest]]] = None,
custom: Optional[Dict[str, object]] = None,
user: Optional[UserRequest] = None,
) -> StreamResponse[PollResponse]:
Expand Down Expand Up @@ -1153,7 +1163,7 @@ def query_polls(
limit: Optional[int] = None,
next: Optional[str] = None,
prev: Optional[str] = None,
sort: Optional[List[Optional[SortParam]]] = None,
sort: Optional[List[Optional[SortParamRequest]]] = None,
filter: Optional[Dict[str, object]] = None,
) -> StreamResponse[QueryPollsResponse]:
query_params = build_query_param(user_id=user_id)
Expand Down Expand Up @@ -1303,7 +1313,7 @@ def query_poll_votes(
limit: Optional[int] = None,
next: Optional[str] = None,
prev: Optional[str] = None,
sort: Optional[List[Optional[SortParam]]] = None,
sort: Optional[List[Optional[SortParamRequest]]] = None,
filter: Optional[Dict[str, object]] = None,
) -> StreamResponse[PollVotesResponse]:
query_params = build_query_param(user_id=user_id)
Expand Down
100 changes: 10 additions & 90 deletions getstream/common/rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ def update_app(
disable_auth_checks: Optional[bool] = None,
disable_permissions_checks: Optional[bool] = None,
enforce_unique_usernames: Optional[str] = None,
feeds_moderation_enabled: Optional[bool] = None,
feeds_v2_region: Optional[str] = None,
image_moderation_enabled: Optional[bool] = None,
migrate_permissions_to_v2: Optional[bool] = None,
moderation_enabled: Optional[bool] = None,
moderation_webhook_url: Optional[str] = None,
multi_tenant_enabled: Optional[bool] = None,
permission_version: Optional[str] = None,
reminders_interval: Optional[int] = None,
Expand All @@ -49,6 +53,7 @@ def update_app(
sqs_url: Optional[str] = None,
video_provider: Optional[str] = None,
webhook_url: Optional[str] = None,
allowed_flag_reasons: Optional[List[str]] = None,
image_moderation_block_labels: Optional[List[str]] = None,
image_moderation_labels: Optional[List[str]] = None,
user_search_disallowed_roles: Optional[List[str]] = None,
Expand Down Expand Up @@ -76,8 +81,12 @@ def update_app(
disable_auth_checks=disable_auth_checks,
disable_permissions_checks=disable_permissions_checks,
enforce_unique_usernames=enforce_unique_usernames,
feeds_moderation_enabled=feeds_moderation_enabled,
feeds_v2_region=feeds_v2_region,
image_moderation_enabled=image_moderation_enabled,
migrate_permissions_to_v2=migrate_permissions_to_v2,
moderation_enabled=moderation_enabled,
moderation_webhook_url=moderation_webhook_url,
multi_tenant_enabled=multi_tenant_enabled,
permission_version=permission_version,
reminders_interval=reminders_interval,
Expand All @@ -91,6 +100,7 @@ def update_app(
sqs_url=sqs_url,
video_provider=video_provider,
webhook_url=webhook_url,
allowed_flag_reasons=allowed_flag_reasons,
image_moderation_block_labels=image_moderation_block_labels,
image_moderation_labels=image_moderation_labels,
user_search_disallowed_roles=user_search_disallowed_roles,
Expand Down Expand Up @@ -353,96 +363,6 @@ def get_import(self, id: str) -> StreamResponse[GetImportResponse]:
"/api/v2/imports/{id}", GetImportResponse, path_params=path_params
)

def unban(
self,
target_user_id: str,
channel_cid: Optional[str] = None,
created_by: Optional[str] = None,
) -> StreamResponse[Response]:
query_params = build_query_param(
target_user_id=target_user_id,
channel_cid=channel_cid,
created_by=created_by,
)

return self.delete(
"/api/v2/moderation/ban", Response, query_params=query_params
)

def ban(
self,
target_user_id: str,
banned_by_id: Optional[str] = None,
channel_cid: Optional[str] = None,
ip_ban: Optional[bool] = None,
reason: Optional[str] = None,
shadow: Optional[bool] = None,
timeout: Optional[int] = None,
user_id: Optional[str] = None,
banned_by: Optional[UserRequest] = None,
user: Optional[UserRequest] = None,
) -> StreamResponse[Response]:
json = build_body_dict(
target_user_id=target_user_id,
banned_by_id=banned_by_id,
channel_cid=channel_cid,
ip_ban=ip_ban,
reason=reason,
shadow=shadow,
timeout=timeout,
user_id=user_id,
banned_by=banned_by,
user=user,
)

return self.post("/api/v2/moderation/ban", Response, json=json)

def flag(
self,
reason: Optional[str] = None,
target_message_id: Optional[str] = None,
target_user_id: Optional[str] = None,
user_id: Optional[str] = None,
custom: Optional[Dict[str, object]] = None,
user: Optional[UserRequest] = None,
) -> StreamResponse[FlagResponse]:
json = build_body_dict(
reason=reason,
target_message_id=target_message_id,
target_user_id=target_user_id,
user_id=user_id,
custom=custom,
user=user,
)

return self.post("/api/v2/moderation/flag", FlagResponse, json=json)

def mute_user(
self,
timeout: int,
user_id: Optional[str] = None,
target_ids: Optional[List[str]] = None,
user: Optional[UserRequest] = None,
) -> StreamResponse[MuteUserResponse]:
json = build_body_dict(
timeout=timeout, user_id=user_id, target_ids=target_ids, user=user
)

return self.post("/api/v2/moderation/mute", MuteUserResponse, json=json)

def unmute_user(
self,
timeout: int,
user_id: Optional[str] = None,
target_ids: Optional[List[str]] = None,
user: Optional[UserRequest] = None,
) -> StreamResponse[UnmuteResponse]:
json = build_body_dict(
timeout=timeout, user_id=user_id, target_ids=target_ids, user=user
)

return self.post("/api/v2/moderation/unmute", UnmuteResponse, json=json)

def get_og(self, url: str) -> StreamResponse[GetOGResponse]:
query_params = build_query_param(url=url)

Expand Down
Loading

0 comments on commit 377f142

Please sign in to comment.