Skip to content

Commit e5e109d

Browse files
kraju3AaronDDM
andauthored
Add tentative_as_busy flag to the availability request (#415)
* Add tentative_as_busy flag to the availability request * Added changelog and fix lint issues * Fix tests * Update the tentative_as_busy property to the availability request * Updated changelog --------- Co-authored-by: Aaron de Mello <[email protected]>
1 parent 414311e commit e5e109d

File tree

5 files changed

+35
-20
lines changed

5 files changed

+35
-20
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ nylas-python Changelog
33

44
Unreleased
55
----------------
6+
* Support for tentative_as_busy parameter that controls whether tentative events are treated as busy time.
7+
* Available as a query parameter for Events requests and as a property in Availability request bodies
68
* Added support for Notetaker APIs
79
* Added support for Notetaker via the calendar and event APIs
810

nylas/models/availability.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,16 @@ class AvailabilityRules(TypedDict):
9090
round_robin_group_id: The ID on events that Nylas considers when calculating the order of
9191
round-robin participants.
9292
This is used for both max-fairness and max-availability methods.
93+
tentative_as_busy: Controls whether tentative calendar events should be treated as busy time.
94+
When set to false, tentative events will be considered as free in availability calculations.
95+
Defaults to true. Only applicable for Microsoft and EWS calendar providers.
9396
"""
9497

9598
availability_method: NotRequired[AvailabilityMethod]
9699
buffer: NotRequired[MeetingBuffer]
97100
default_open_hours: NotRequired[List[OpenHours]]
98101
round_robin_group_id: NotRequired[str]
102+
tentative_as_busy: NotRequired[bool]
99103

100104

101105
class AvailabilityParticipant(TypedDict):

nylas/models/events.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,8 @@ class ListEventQueryParams(ListQueryParams):
822822
You can pass the query parameter multiple times to select or exclude multiple event types.
823823
master_event_id (NotRequired[str]): Filter for instances of recurring events with the
824824
specified master_event_id. Not respected by metadata filtering.
825+
tentative_as_busy: When set to false, treats tentative calendar events as busy:false.
826+
Only applicable for Microsoft and EWS calendar providers. Defaults to true.
825827
select: Comma-separated list of fields to return in the response.
826828
This allows you to receive only the portion of object data that you're interested in.
827829
limit (NotRequired[int]): The maximum number of objects to return.
@@ -844,6 +846,7 @@ class ListEventQueryParams(ListQueryParams):
844846
event_type: NotRequired[List[EventType]]
845847
master_event_id: NotRequired[str]
846848
select: NotRequired[str]
849+
tentative_as_busy: NotRequired[bool]
847850

848851

849852
class CreateEventQueryParams(TypedDict):
@@ -853,10 +856,13 @@ class CreateEventQueryParams(TypedDict):
853856
Attributes:
854857
calendar_id: The ID of the calendar to create the event in.
855858
notify_participants: Email notifications containing the calendar event is sent to all event participants.
859+
tentative_as_busy: When set to false, treats tentative calendar events as busy:false.
860+
Only applicable for Microsoft and EWS calendar providers. Defaults to true.
856861
"""
857862

858863
calendar_id: str
859864
notify_participants: NotRequired[bool]
865+
tentative_as_busy: NotRequired[bool]
860866

861867

862868
class FindEventQueryParams(TypedDict):
@@ -866,9 +872,12 @@ class FindEventQueryParams(TypedDict):
866872
Attributes:
867873
calendar_id: Calendar ID to find the event in.
868874
"primary" is a supported value indicating the user's primary calendar.
875+
tentative_as_busy: When set to false, treats tentative calendar events as busy:false.
876+
Only applicable for Microsoft and EWS calendar providers. Defaults to true.
869877
"""
870878

871879
calendar_id: str
880+
tentative_as_busy: NotRequired[bool]
872881

873882

874883
UpdateEventQueryParams = CreateEventQueryParams

nylas/resources/calendars.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,7 @@ def destroy(
163163
path=f"/v3/grants/{identifier}/calendars/{calendar_id}", overrides=overrides
164164
)
165165

166-
def get_availability(
167-
self, request_body: GetAvailabilityRequest, overrides: RequestOverrides = None
166+
def get_availability(self, request_body: GetAvailabilityRequest, overrides: RequestOverrides = None
168167
) -> Response[GetAvailabilityResponse]:
169168
"""
170169
Get availability for a Calendar.

tests/resources/test_calendars.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -342,26 +342,27 @@ def test_get_availability(self, http_client_response):
342342
],
343343
}
344344
],
345-
"locale": "en",
345+
"duration_minutes": 60,
346+
"interval_minutes": 30,
347+
"round_to_30_minutes": True,
348+
"availability_rules": {
349+
"availability_method": "max-availability",
350+
"buffer": {"before": 10, "after": 10},
351+
"default_open_hours": [
352+
{
353+
"days": [0],
354+
"timezone": "America/Los_Angeles",
355+
"start": "09:00",
356+
"end": "17:00",
357+
"exdates": ["2021-03-01"],
358+
}
359+
],
360+
"round_robin_group_id": "event-123",
361+
"tentative_as_busy": False
362+
},
346363
}
347364

348-
# Set up mock response data
349-
http_client_response._execute.return_value = ({
350-
"availability": [
351-
{
352-
"end_time": 1497960800,
353-
"start_time": 1497960600,
354-
"status": "free",
355-
"object": "availability_status",
356-
}
357-
],
358-
"object": "availability",
359-
"time_slots": [
360-
{"end_time": 1497960800, "start_time": 1497960600, "status": "free"}
361-
],
362-
}, {})
363-
364-
calendars.get_availability(request_body=request_body)
365+
calendars.get_availability(request_body,overrides=None,)
365366

366367
http_client_response._execute.assert_called_once_with(
367368
"POST",

0 commit comments

Comments
 (0)