Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
repos:
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 26.1.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 7.0.0
hooks:
- id: isort
name: isort
args: [--profile, black, --skip, migrations]
- repo: https://github.com/pycqa/flake8
rev: "6.0.0" # pick a git hash / tag to point to
rev: "7.3.0"
hooks:
- id: flake8
additional_dependencies: ["pyflakes>=3.2.0"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.2.0"
rev: "v1.19.1"
hooks:
- id: mypy
args: [--no-strict-optional, --ignore-missing-imports]
Expand Down
13 changes: 5 additions & 8 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
"python.analysis.inlayHints.functionReturnTypes": true,
"editor.formatOnSave": true,
"isort.check": true,
"isort.args": [
"--profile",
"black"
],
"isort.args": ["--profile", "black"],
"python.testing.pytestEnabled": true,
"python.testing.pytestArgs": [
"tests",
Expand All @@ -38,7 +35,7 @@
],
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
"source.organizeImports": "explicit"
},
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.codeLens": true
Expand All @@ -50,6 +47,6 @@
"files.exclude": {
"**/__pycache__": true,
"**/.pytest_cache": true,
"**/.mypy*": true,
},
}
"**/.mypy*": true
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ setup_logs(log_level=logging.DEBUG)

1. get webinar live stream
2. update webinar live stream
3. update webinar livestream status
3. update webinar livestream status - Following [Zoom documentation](https://developers.zoom.us/docs/api/rest/reference/zoom-api/methods/#operation/meetingLiveStreamStatusUpdate).

### **zoom rooms**:

Expand Down
4 changes: 1 addition & 3 deletions example/get_meeting_livestream.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@
MEETING_ID = os.environ["MEETING_ID"]


result = zoom_client.meeting_livestreams.get_livestream(
MEETING_ID,
)
result = zoom_client.meeting_livestreams.get_livestream(MEETING_ID)
print(result)
26 changes: 26 additions & 0 deletions example/start_meeting_livestream.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import logging
import os

from zoom_python_client.utils.logger import setup_logs
from zoom_python_client.zoom_api_client import ZoomApiClient

setup_logs(log_level=logging.DEBUG)
zoom_client = ZoomApiClient.init_from_dotenv()
MEETING_ID = os.environ["MEETING_ID"]


result = zoom_client.meeting_livestreams.get_livestream(MEETING_ID)
print(result)

settings = {
"active_speaker_name": False,
"display_name": "CERN_Webcast_Service",
"layout": "follow_host",
"close_caption": "embedded",
}
started = zoom_client.meeting_livestreams.update_livestream_status(
MEETING_ID,
"start",
settings=settings,
)
print(started)
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
python-dotenv==1.0.0
requests==2.31.0
typing_extensions==4.7.1
typing_extensions==4.7.1
typed-ast==1.5.5
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,29 @@ def test_update_meeting_livestreams_component_no_response(self):

@responses.activate
def test_update_meeting_livestreams_status_component(self):
settings = {
"active_speaker_name": False,
"display_name": "CERN_Webcast_Service",
"layout": "follow_host",
"close_caption": "embedded",
}
responses.add(
responses.PATCH,
"http://localhost/meetings/12345/livestream/status",
status=204,
match=[
responses.matchers.json_params_matcher(
{"action": "start", "settings": settings}
)
],
)
zoom_client = ZoomApiClient("aaa", "bbb", "ccc", "http://localhost")
component = MeetingLiveStreamsComponent(zoom_client)
result = component.update_livestream_status("12345", "start")
result = component.update_livestream_status(
"12345",
"start",
settings=settings,
)
assert result

@responses.activate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,29 @@ def test_update_webinar_livestreams_component_no_response(self):

@responses.activate
def test_update_webinar_livestreams_status_component(self):
settings = {
"active_speaker_name": False,
"display_name": "CERN_Webcast_Service",
"layout": "follow_host",
"close_caption": "embedded",
}
responses.add(
responses.PATCH,
"http://localhost/webinars/12345/livestream/status",
status=204,
match=[
responses.matchers.json_params_matcher(
{"action": "start", "settings": settings}
)
],
)
zoom_client = ZoomApiClient("aaa", "bbb", "ccc", "http://localhost")
component = WebinarLiveStreamsComponent(zoom_client)
result = component.update_livestream_status("12345", "start")
result = component.update_livestream_status(
"12345",
"start",
settings=settings,
)
assert result

@responses.activate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from json import JSONDecodeError
from typing import TypedDict
from typing import Any, Dict, Optional

from typing_extensions import NotRequired, TypedDict

from zoom_python_client.zoom_auth_api.zoom_auth_api_client import ZoomAuthApiClientError
from zoom_python_client.zoom_client_interface import ZoomClientInterface
Expand All @@ -14,6 +16,7 @@ class LiveStreamDict(TypedDict):

class LiveStreamStatusDict(TypedDict):
action: str
settings: NotRequired[Dict[str, Any]]


class MeetingLiveStreamsComponent:
Expand Down Expand Up @@ -41,9 +44,16 @@ def update_livestream(self, meeting_id: str, data: LiveStreamDict) -> bool:
return True
return False

def update_livestream_status(self, meeting_id: str, action: str) -> bool:
def update_livestream_status(
self,
meeting_id: str,
action: str,
settings: Optional[Dict[str, Any]] = None,
) -> bool:
api_path = f"/meetings/{meeting_id}/livestream/status"
data: LiveStreamStatusDict = {"action": action}
if settings is not None:
data["settings"] = settings
response = self.client.make_patch_request(api_path, data)
if response and response.status_code == 204:
return True
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from json import JSONDecodeError
from typing import TypedDict
from typing import Any, Dict, Optional

from typing_extensions import NotRequired, TypedDict

from zoom_python_client.zoom_auth_api.zoom_auth_api_client import ZoomAuthApiClientError
from zoom_python_client.zoom_client_interface import ZoomClientInterface
Expand All @@ -14,6 +16,7 @@ class LiveStreamDict(TypedDict):

class LiveStreamStatusDict(TypedDict):
action: str
settings: NotRequired[Dict[str, Any]]


class WebinarLiveStreamsComponent:
Expand All @@ -38,9 +41,16 @@ def update_livestream(self, meeting_id: str, data: LiveStreamDict) -> bool:
return True
return False

def update_livestream_status(self, meeting_id: str, action: str) -> bool:
def update_livestream_status(
self,
meeting_id: str,
action: str,
settings: Optional[Dict[str, Any]] = None,
) -> bool:
api_path = f"/webinars/{meeting_id}/livestream/status"
data: LiveStreamStatusDict = {"action": action}
if settings is not None:
data["settings"] = settings
response = self.client.make_patch_request(api_path, data)
if response.status_code == 204:
return True
Expand Down
2 changes: 1 addition & 1 deletion zoom_python_client/utils/typed_dict_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class DataType(TypedDict, total=False):
...
pass


def generate_parameters_dict(data: DataType) -> dict:
Expand Down