Skip to content

Commit 49daf38

Browse files
committed
Adds get_event for calendar. Adds param calendar_id to list_events in calendar.
1 parent d8f63c0 commit 49daf38

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ response = client.notes.create_page(section_id, files)
100100
### Calendar
101101
#### Get events
102102
```
103-
response = client.calendar.list_events()
103+
response = client.calendar.list_events(calendar_id)
104+
```
105+
106+
#### Get event
107+
```
108+
response = client.calendar.get_event(event_id)
104109
```
105110

106111
#### Create calendar event

microsoftgraph/calendar.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,34 @@ def __init__(self, client) -> None:
1515
self._client = client
1616

1717
@token_required
18-
def list_events(self) -> Response:
18+
def list_events(self, calendar_id: str = None) -> Response:
1919
"""Get a list of event objects in the user's mailbox. The list contains single instance meetings and series
2020
masters.
2121
2222
https://docs.microsoft.com/en-us/graph/api/user-list-events?view=graph-rest-1.0&tabs=http
2323
24+
Args:
25+
calendar_id (str): Calendar ID.
26+
27+
Returns:
28+
Response: Microsoft Graph Response.
29+
"""
30+
url = "me/calendars/{}/events".format(calendar_id) if calendar_id else "me/events"
31+
return self._client._get(self._client.base_url + url)
32+
33+
@token_required
34+
def get_event(self, event_id: str) -> Response:
35+
"""Get the properties and relationships of the specified event object.
36+
37+
https://docs.microsoft.com/en-us/graph/api/event-get?view=graph-rest-1.0&tabs=http
38+
39+
Args:
40+
event_id (str): Event ID.
41+
2442
Returns:
2543
Response: Microsoft Graph Response.
2644
"""
27-
return self._client._get(self._client.base_url + "me/events")
45+
return self._client._get(self._client.base_url + "me/events/{}".format(event_id))
2846

2947
@token_required
3048
def create_event(
@@ -36,7 +54,7 @@ def create_event(
3654
end_datetime: datetime,
3755
end_timezone: str,
3856
location: str,
39-
calendar: str = None,
57+
calendar_id: str = None,
4058
content_type: str = "HTML",
4159
**kwargs,
4260
) -> Response:
@@ -54,7 +72,7 @@ def create_event(
5472
end_datetime (str): A single point of time in a combined date and time representation ({date}T{time}; for
5573
end_timezone (str): Represents a time zone, for example, "Pacific Standard Time".
5674
location (str): The location of the event.
57-
calendar (str, optional): Calendar ID. Defaults to None.
75+
calendar_id (str, optional): Calendar ID. Defaults to None.
5876
content_type (str, optional): It can be in HTML or text format. Defaults to HTML.
5977
6078
Returns:
@@ -81,7 +99,7 @@ def create_event(
8199
},
82100
"location": {"displayName": location},
83101
}
84-
url = "me/calendars/{}/events".format(calendar) if calendar is not None else "me/events"
102+
url = "me/calendars/{}/events".format(calendar_id) if calendar_id is not None else "me/events"
85103
return self._client._post(self._client.base_url + url, json=body)
86104

87105
@token_required

0 commit comments

Comments
 (0)