Skip to content

Commit

Permalink
Merge pull request #28 from cern-vc/develop
Browse files Browse the repository at this point in the history
🚀 RELEASE: Bump to v0.2.3
  • Loading branch information
SamuelGuillemet committed Aug 30, 2023
2 parents 18e426f + 1a0b919 commit 8d8ced9
Show file tree
Hide file tree
Showing 11 changed files with 247 additions and 12 deletions.
57 changes: 47 additions & 10 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,55 @@
{
"terminal.integrated.env.osx": {
"PYTHONPATH": "${workspaceFolder}"
},
"terminal.integrated.env.linux": {
"PYTHONPATH": "${workspaceFolder}"
},
"python.analysis.autoSearchPaths": true,
"python.analysis.autoImportCompletions": true,
"python.analysis.indexing": true,
"python.analysis.packageIndexDepths": [
{
"name": "pytest",
"depth": 2
},
{
"name": "unittest",
"depth": 2
}
],
"python.analysis.typeCheckingMode": "basic",
"python.analysis.inlayHints.callArgumentNames": true,
"python.analysis.inlayHints.variableTypes": true,
"python.analysis.inlayHints.functionReturnTypes": true,
"editor.formatOnSave": true,
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.linting.pylintPath": "venv/bin/pylint",
"terminal.integrated.env.osx": {
"PYTHONPATH": "${workspaceFolder}"
"isort.check": true,
"isort.args": [
"--profile",
"black"
],
"python.testing.pytestEnabled": true,
"python.testing.pytestArgs": [
"tests",
"-vv",
"--cov=app",
"--cov-report=term-missing",
"--cov-report=html"
],
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.codeLens": true
},
"search.exclude": {
"**/dist": true,
"**/venv": true
"**/.venv": true
},
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
}
}
"files.exclude": {
"**/__pycache__": true,
"**/.pytest_cache": true,
"**/.mypy*": true,
},
}
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,10 @@ setup_logs(log_level=logging.DEBUG)
1. get all zoom rooms
2. get zoom room details
3. get zoom room sensor data

### **calendars**:

1. get calendar services list
2. get calendar resources list
3. get calendar resources by service id list
4. get calendar resource details by id
32 changes: 32 additions & 0 deletions example/get_microsoft_user_id_for_rooms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import logging

from zoom_python_client.client_components.rooms.rooms_component import (
RoomsListDict,
RoomType,
)
from zoom_python_client.utils.logger import setup_logs
from zoom_python_client.zoom_api_client import ZoomApiClient

logger = setup_logs(log_level=logging.INFO)

zoom_client = ZoomApiClient.init_from_dotenv(use_path=".")

parameters = RoomsListDict(
type=RoomType.ZOOM_ROOM,
)

rooms = zoom_client.rooms.get_rooms(parameters)

logger.info("Found %d rooms:", len(rooms["rooms"]))
for room in rooms["rooms"]:
room_profile = zoom_client.rooms.get_room(room["id"])

calendar_ressource = zoom_client.calendars.get_calendar_resource_by_ressource_id(
room_profile["basic"]["calendar_resource_id"]
)

logger.info(
"\t- Microsoft user id for room %s is %s",
room["name"],
calendar_ressource["calendar_resource_email"],
)
21 changes: 21 additions & 0 deletions example/list_calendar_ressources.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import logging

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

logger = setup_logs(log_level=logging.DEBUG)

zoom_client = ZoomApiClient.init_from_dotenv(use_path=".")


result = zoom_client.calendars.list_calendar_resources()

logger.info("Found %d calendars:", len(result))

for calendar_ressources in result:
logger.info(
"\t- %s - %s - %s",
calendar_ressources["calendar_resource_name"],
calendar_ressources["calendar_resource_id"],
calendar_ressources["calendar_resource_email"],
)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "zoom-python-client"
version = "0.2.1"
version = "0.2.2"
authors = ["Rene Fernandez Sanchez <rene.fernandez@cern.ch>"]
maintainers = [
"Rene Fernandez Sanchez <rene.fernandez@cern.ch>",
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import pytest
import responses

from tests.zoom_python_client.base_test_case import TestCaseWithAuth
from zoom_python_client.client_components.calendars.calendars_component import (
CalendarsComponent,
)
from zoom_python_client.zoom_api_client import ZoomApiClient


class TestCalendarsComponent(TestCaseWithAuth):
def setUp(self):
super().setUp()
zoom_client = ZoomApiClient("aaa", "bbb", "ccc", "http://localhost")
self.calendars_component = CalendarsComponent(zoom_client)

@responses.activate
def test_list_calendar_services(self):
responses.add(
responses.GET,
"http://localhost/rooms/calendar/services",
json={"response": "ok"},
status=200,
)
calendar_services = self.calendars_component.list_calendar_services()
assert calendar_services == {"response": "ok"}

@responses.activate
def test_list_calendar_resources(self):
responses.add(
responses.GET,
"http://localhost/rooms/calendar/services",
json={"calendar_services": [{"calendar_service_id": "12345"}]},
status=200,
)
responses.add(
responses.GET,
"http://localhost/rooms/calendar/services/12345/resources",
json={"calendar_resources": [{"calendar_resource_id": "12345"}]},
status=200,
)
calendar_resources = self.calendars_component.list_calendar_resources()
assert calendar_resources == [{"calendar_resource_id": "12345"}]

@responses.activate
def test_list_calendar_resources_by_service_id(self):
responses.add(
responses.GET,
"http://localhost/rooms/calendar/services/12345/resources",
json={"response": "ok"},
status=200,
)
calendar_resources = (
self.calendars_component.list_calendar_resources_by_service_id("12345")
)
assert calendar_resources == {"response": "ok"}

@responses.activate
def test_get_calendar_resource_by_ressource_id(self):
responses.add(
responses.GET,
"http://localhost/rooms/calendar/services",
json={"calendar_services": [{"calendar_service_id": "12345"}]},
status=200,
)
responses.add(
responses.GET,
"http://localhost/rooms/calendar/services/12345/resources",
json={"calendar_resources": [{"calendar_resource_id": "12345"}]},
status=200,
)
calendar_resource = (
self.calendars_component.get_calendar_resource_by_ressource_id("12345")
)
assert calendar_resource == {"calendar_resource_id": "12345"}

@responses.activate
def test_get_calendar_resource_by_ressource_id_not_found(self):
responses.add(
responses.GET,
"http://localhost/rooms/calendar/services",
json={"calendar_services": [{"calendar_service_id": "12345"}]},
status=200,
)
responses.add(
responses.GET,
"http://localhost/rooms/calendar/services/12345/resources",
json={"calendar_resources": [{"calendar_resource_id": "12345"}]},
status=200,
)
with pytest.raises(ValueError):
self.calendars_component.get_calendar_resource_by_ressource_id("123456")
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from typing import Any

from zoom_python_client.zoom_client_interface import ZoomClientInterface


class CalendarsComponent:
def __init__(self, client: ZoomClientInterface) -> None:
self.client = client

def list_calendar_services(self) -> dict:
api_path = "/rooms/calendar/services"
response = self.client.make_get_request(api_path)
result = response.json()
return result

def list_calendar_resources(self) -> list[Any]:
calendar_services = self.list_calendar_services()
calendar_service_ids = [
calendar_service["calendar_service_id"]
for calendar_service in calendar_services["calendar_services"]
]
calendar_resources = []
for calendar_service_id in calendar_service_ids:
res = self.list_calendar_resources_by_service_id(calendar_service_id)
for resource in res["calendar_resources"]:
calendar_resources.append(resource)

return calendar_resources

def list_calendar_resources_by_service_id(self, calendar_service_id: str) -> dict:
api_path = f"/rooms/calendar/services/{calendar_service_id}/resources"
response = self.client.make_get_request(api_path)
result = response.json()
return result

def get_calendar_resource_by_ressource_id(self, resource_id: str) -> dict:
all_ressources = self.list_calendar_resources()
for resource in all_ressources:
if resource["calendar_resource_id"] == resource_id:
return resource

raise ValueError(f"Resource with id {resource_id} not found")
4 changes: 4 additions & 0 deletions zoom_python_client/zoom_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
from dotenv import load_dotenv

from zoom_python_client.api_client import ApiClient
from zoom_python_client.client_components.calendars.calendars_component import (
CalendarsComponent,
)
from zoom_python_client.client_components.meeting_livestreams.meeting_livestreams_component import (
MeetingLiveStreamsComponent,
)
Expand Down Expand Up @@ -74,6 +77,7 @@ def init_components(self):
self.webinars = WebinarsComponent(self)
self.webinar_livestreams = WebinarLiveStreamsComponent(self)
self.rooms = RoomsComponent(self)
self.calendars = CalendarsComponent(self)

def __init__(
self,
Expand Down
2 changes: 1 addition & 1 deletion zoom_python_client/zoom_auth_api/zoom_auth_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,5 @@ def get_expire_seconds_from_file(self):
with open(file_path, "r") as token_file:
access_token = token_file.read()
return access_token
except FileNotFoundError:
except FileNotFoundError: # pragma: no cover
return None

0 comments on commit 8d8ced9

Please sign in to comment.