Repository navigation
[TT-5545] feat(events): add events.batch() for the Events batch endpoint - #493
Merged
pengfeiye merged 3 commits intoNov 4, 2026
Merged
Conversation
Add Events.batch() for POST /v3/grants/{grant_id}/events/batch, which runs
create, update, and delete operations in one request (Google and Microsoft).
- BatchCreateEventOperation, BatchUpdateEventOperation, and
BatchDeleteEventOperation reuse CreateEventRequest and UpdateEventRequest
as the operation bodies.
- BatchEventsQueryParams extends CreateEventQueryParams with grant_email
and select.
- BatchEventResult reuses Event and NylasApiErrorResponseData, and adds
retry_after and provider_event_created.
- A 207 response returns the per-operation results. A 400 response raises
NylasApiError, as for any other endpoint.
- Add the examples/events_batch_demo example with retry guidance, and a
CHANGELOG entry.
Co-authored-by: Cursor <cursoragent@cursor.com>
pengfeiye
had a problem deploying
to
sdk-reference
November 4, 2026 16:10 — with
GitHub Actions
Failure
AaronDDM
approved these changes
Nov 4, 2026
…batch The batch models pushed nylas/models/events.py past pylint's 1000-line module limit (too-many-lines). Move them to their own module, as the free/busy and availability models are for Calendars, and apply black formatting to the new test helper and example. Co-authored-by: Cursor <cursoragent@cursor.com>
pengfeiye
had a problem deploying
to
sdk-reference
November 4, 2026 16:35 — with
GitHub Actions
Failure
2 of 3 tasks
ubuntu-latest now resolves to ubuntu-26.04, and actions/python-versions has no Python 3.8 build for 26.04 (its builds start at 3.10). setup-python fails with "Version 3.8 with arch x64 not found", so the Python 3.8, Pylint and Black, and docs jobs fail on every PR, and fail-fast cancels Python 3.x. Pin these jobs to ubuntu-24.04, the image they last passed on, where setup-python downloads python-3.8.18-linux-24.04-x64. Co-authored-by: Cursor <cursoragent@cursor.com> (cherry picked from commit 6523e56)
3 of 4 tasks
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://nylas.atlassian.net/browse/TT-5545
Summary
The v3 API has a new endpoint,
POST /v3/grants/{grant_id}/events/batch, that runs many event create, update, and delete operations in one HTTP call. Only Google and Microsoft grants support it. This addsevents.batch()to the Python SDK, following the SDK spec in TT-5542.Changes
Events.batch(identifier, request_body, query_params, overrides=None), which returnsResponse[List[BatchEventResult]].nylas.models.events_batch, for the batch models. A separate module keepsnylas/models/events.pyunder pylint's 1000-line limit, the same way the free/busy and availability models live outsidecalendars.py.BatchCreateEventOperation,BatchUpdateEventOperation, andBatchDeleteEventOperation(combined asBatchEventOperation), andBatchEventsRequest. Each operation is a TypedDict with aLiteralmethod, so a type checker flags an update or delete withoutevent_id, and a create or update withoutbody. The operation bodies reuseCreateEventRequestandUpdateEventRequest.BatchEventsQueryParamsextendsCreateEventQueryParams(the query params of create, update, and delete) withgrant_emailandselect.BatchEventResulthasstatus,data(the existingEvent),error(the existingNylasApiErrorResponseData, which has the API's normal error shape),retry_after(integer seconds;0is kept as0), andprovider_event_created. Results are decoded withinfer_missing=True, asListResponsedoes, so the partial events thatselectreturns are deserialized instead of raising aKeyError._validate_response, and throughevents.batch()with onlyrequests.requestmocked.examples/events_batch_demo(a README and a runnable script). It shows how to loop over the results, retry items with status429or503afterretry_after, and never retry items withprovider_event_created: true. Link the example from the main README, and add a CHANGELOG entry.BatchEventResult.from_dictto pylint'sgenerated-members.Why there is no dedicated response type: the spec suggests one because the list wrapper has a
next_cursor. In this SDK,Responsealready holds onlydata,request_id, andheaders, andcalendars.get_free_busy()already returnsResponse[List[...]]. Sobatch()reusesResponse, which also keeps destructuring working:results, request_id, headers = nylas.events.batch(...).Testing
tests/resources/test_events.pyand 1 intests/handler/test_http_client.py.Eventfor create and update and nodatafor deletestatus,error.type,error.message,retry_after, andprovider_event_createdretry_after: 0deserializes as0NylasApiErrorwithrequest_id,type, andmessageprovider_event_createdand 404 items were not.pylint nylaslocally (pylint 4.1.3, Python 3.10): no new messages compared withmain. black reports no changes for the new code.ubuntu-latestis now ubuntu-26.04, which has no Python 3.8, so every 3.8 job fails at "Setup python" on every PR. fix(ci): pin Python 3.8 jobs to ubuntu-24.04 #494 fixes this. After fix(ci): pin Python 3.8 jobs to ubuntu-24.04 #494 merges, mergemaininto this branch to rerun the checks.event_id(expects 207), and one delete batch.Related
License
I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner.