0
# Attendees and People
1
2
GCSA provides comprehensive attendee management through the Attendee and Person classes. These classes handle event participants, organizers, RSVP status tracking, and participant permissions for collaborative calendar usage.
3
4
## Package Information
5
6
```python
7
from gcsa.attendee import Attendee, ResponseStatus
8
from gcsa.person import Person
9
from gcsa.event import Event
10
```
11
12
## Attendee Class
13
14
### Basic Attendee Creation
15
16
```python { .api }
17
class Attendee(Person):
18
def __init__(
19
self,
20
email: str,
21
display_name = None,
22
comment = None,
23
optional = None,
24
is_resource = None,
25
additional_guests = None,
26
_id = None,
27
_is_self = None,
28
_response_status = None
29
):
30
"""
31
Create an event attendee.
32
33
:param email: Attendee's email address (required)
34
:param display_name: Display name for the attendee
35
:param comment: Comment added by attendee when responding
36
:param optional: Whether attendance is optional (True) or required (False)
37
:param is_resource: Whether this represents a resource (room, equipment) rather than person
38
:param additional_guests: Number of additional guests attendee can bring
39
:param _id: Attendee identifier (read-only)
40
:param _is_self: Whether this attendee is the authenticated user (read-only)
41
:param _response_status: Current response status (read-only, use ResponseStatus constants)
42
"""
43
```
44
45
### Attendee Properties
46
47
All Attendee objects inherit from Person and have additional attendee-specific properties for managing event participation.
48
49
## Person Class
50
51
### Basic Person Creation
52
53
```python { .api }
54
class Person:
55
def __init__(
56
self,
57
email: str,
58
display_name = None,
59
_id = None,
60
_is_self = None
61
):
62
"""
63
Create a person object for organizers, creators, or attendees.
64
65
:param email: Person's email address (required)
66
:param display_name: Display name for the person
67
:param _id: Person identifier (read-only)
68
:param _is_self: Whether this person is the authenticated user (read-only)
69
"""
70
```
71
72
## Response Status Constants
73
74
```python { .api }
75
class ResponseStatus:
76
NEEDS_ACTION = "needsAction" # No response yet (default)
77
DECLINED = "declined" # Declined invitation
78
TENTATIVE = "tentative" # Tentatively accepted
79
ACCEPTED = "accepted" # Accepted invitation
80
```
81
82
## Adding Attendees to Events
83
84
### Single Attendee Addition
85
86
```python { .api }
87
def add_attendee(self, attendee):
88
"""
89
Add a single attendee to the event.
90
91
:param attendee: Attendee object to add to the event
92
"""
93
94
def add_attendees(self, attendees):
95
"""
96
Add multiple attendees to the event.
97
98
:param attendees: List of Attendee objects to add to the event
99
"""
100
```
101
102
## Basic Usage Examples
103
104
### Creating Events with Attendees
105
106
```python
107
from gcsa.google_calendar import GoogleCalendar
108
from gcsa.event import Event
109
from gcsa.attendee import Attendee, ResponseStatus
110
from datetime import datetime
111
112
gc = GoogleCalendar()
113
114
# Create attendees
115
organizer = Attendee(
116
email="organizer@example.com",
117
display_name="Meeting Organizer"
118
)
119
120
required_attendee = Attendee(
121
email="john.doe@example.com",
122
display_name="John Doe",
123
optional=False
124
)
125
126
optional_attendee = Attendee(
127
email="jane.smith@example.com",
128
display_name="Jane Smith",
129
optional=True,
130
additional_guests=2 # Can bring 2 additional guests
131
)
132
133
# Create event with attendees
134
meeting = Event(
135
summary="Team Planning Meeting",
136
start=datetime(2024, 2, 15, 10, 0),
137
end=datetime(2024, 2, 15, 11, 30),
138
description="Planning for Q2 objectives",
139
attendees=[organizer, required_attendee, optional_attendee]
140
)
141
142
gc.add_event(meeting)
143
```
144
145
### Adding Attendees to Existing Events
146
147
```python
148
from gcsa.attendee import Attendee
149
150
# Get existing event
151
event = gc.get_event("event_id")
152
153
# Add single attendee
154
new_attendee = Attendee(
155
email="newperson@example.com",
156
display_name="New Person",
157
optional=True
158
)
159
event.add_attendee(new_attendee)
160
161
# Add multiple attendees
162
additional_attendees = [
163
Attendee("alice@example.com", display_name="Alice"),
164
Attendee("bob@example.com", display_name="Bob", optional=True)
165
]
166
event.add_attendees(additional_attendees)
167
168
# Update the event
169
gc.update_event(event, send_updates="all")
170
```
171
172
### Resource Attendees
173
174
```python
175
from gcsa.attendee import Attendee
176
from gcsa.event import Event
177
from datetime import datetime
178
179
# Book a conference room as an attendee
180
conference_room = Attendee(
181
email="conference-room-a@example.com",
182
display_name="Conference Room A",
183
is_resource=True # Indicates this is a resource, not a person
184
)
185
186
# Book equipment as attendees
187
projector = Attendee(
188
email="projector-1@example.com",
189
display_name="Projector #1",
190
is_resource=True
191
)
192
193
meeting = Event(
194
summary="Board Meeting",
195
start=datetime(2024, 3, 1, 14, 0),
196
end=datetime(2024, 3, 1, 16, 0),
197
attendees=[
198
Attendee("ceo@example.com", display_name="CEO"),
199
Attendee("cfo@example.com", display_name="CFO"),
200
conference_room, # Room booking
201
projector # Equipment booking
202
]
203
)
204
205
gc.add_event(meeting)
206
```
207
208
### Managing Guest Permissions
209
210
```python
211
from gcsa.event import Event
212
from gcsa.attendee import Attendee
213
from datetime import datetime
214
215
# Create event with specific guest permissions
216
event = Event(
217
summary="Confidential Planning Session",
218
start=datetime(2024, 2, 20, 9, 0),
219
end=datetime(2024, 2, 20, 10, 0),
220
guests_can_invite_others=False, # Guests cannot invite others
221
guests_can_modify=False, # Guests cannot modify event
222
guests_can_see_other_guests=True, # Guests can see other attendees
223
attendees=[
224
Attendee("manager@example.com", display_name="Manager"),
225
Attendee("lead@example.com", display_name="Team Lead")
226
]
227
)
228
229
gc.add_event(event)
230
```
231
232
### Working with Response Status
233
234
```python
235
from gcsa.google_calendar import GoogleCalendar
236
from gcsa.attendee import ResponseStatus
237
238
gc = GoogleCalendar()
239
240
# Get event with attendees
241
event = gc.get_event("event_id")
242
243
# Check attendee responses
244
print("Attendee responses:")
245
for attendee in event.attendees:
246
status = getattr(attendee, '_response_status', ResponseStatus.NEEDS_ACTION)
247
print(f"- {attendee.display_name or attendee.email}: {status}")
248
249
# Filter attendees by response status
250
accepted_attendees = [
251
attendee for attendee in event.attendees
252
if getattr(attendee, '_response_status') == ResponseStatus.ACCEPTED
253
]
254
255
declined_attendees = [
256
attendee for attendee in event.attendees
257
if getattr(attendee, '_response_status') == ResponseStatus.DECLINED
258
]
259
260
print(f"Accepted: {len(accepted_attendees)}")
261
print(f"Declined: {len(declined_attendees)}")
262
```
263
264
### Attendee Comments and Additional Guests
265
266
```python
267
from gcsa.attendee import Attendee
268
from gcsa.event import Event
269
from datetime import datetime
270
271
# Attendee with comment and additional guest allowance
272
attendee_with_comment = Attendee(
273
email="expert@example.com",
274
display_name="Industry Expert",
275
comment="Looking forward to sharing insights on market trends",
276
additional_guests=1 # Can bring one additional guest
277
)
278
279
networking_event = Event(
280
summary="Industry Networking Event",
281
start=datetime(2024, 4, 15, 18, 0),
282
end=datetime(2024, 4, 15, 20, 0),
283
location="Grand Hotel Ballroom",
284
attendees=[attendee_with_comment]
285
)
286
287
gc.add_event(networking_event)
288
```
289
290
### Large Events with Many Attendees
291
292
```python
293
from gcsa.attendee import Attendee
294
from gcsa.event import Event
295
from datetime import datetime
296
297
# Create event with many attendees
298
attendee_emails = [
299
"employee1@example.com",
300
"employee2@example.com",
301
"employee3@example.com",
302
# ... many more
303
]
304
305
all_hands_attendees = []
306
for email in attendee_emails:
307
attendee = Attendee(
308
email=email,
309
display_name=email.split('@')[0].replace('.', ' ').title()
310
)
311
all_hands_attendees.append(attendee)
312
313
all_hands_meeting = Event(
314
summary="All Hands Meeting",
315
start=datetime(2024, 3, 15, 9, 0),
316
end=datetime(2024, 3, 15, 10, 0),
317
description="Company-wide quarterly update",
318
attendees=all_hands_attendees
319
)
320
321
gc.add_event(all_hands_meeting)
322
```
323
324
### Working with External Attendees
325
326
```python
327
from gcsa.attendee import Attendee
328
from gcsa.event import Event
329
from datetime import datetime
330
331
# Mix of internal and external attendees
332
internal_attendees = [
333
Attendee("john@mycompany.com", display_name="John (Internal)"),
334
Attendee("sarah@mycompany.com", display_name="Sarah (Internal)")
335
]
336
337
external_attendees = [
338
Attendee("client@othercorp.com", display_name="Client Representative"),
339
Attendee("vendor@supplier.com", display_name="Vendor Contact")
340
]
341
342
# Create client meeting with mixed attendees
343
client_meeting = Event(
344
summary="Client Review Meeting",
345
start=datetime(2024, 2, 28, 14, 0),
346
end=datetime(2024, 2, 28, 15, 30),
347
attendees=internal_attendees + external_attendees,
348
guests_can_see_other_guests=False # Hide attendee list from externals
349
)
350
351
# Send updates only to external attendees when updating
352
gc.add_event(client_meeting)
353
gc.update_event(client_meeting, send_updates="externalOnly")
354
```
355
356
### Self-Service Event Sign-ups
357
358
```python
359
from gcsa.event import Event
360
from gcsa.attendee import Attendee
361
from datetime import datetime
362
363
# Create event that allows self-registration
364
workshop = Event(
365
summary="Python Workshop",
366
start=datetime(2024, 3, 20, 10, 0),
367
end=datetime(2024, 3, 20, 16, 0),
368
description="Learn Python basics in this hands-on workshop",
369
location="Training Room B",
370
anyone_can_add_self=True, # Allow people to add themselves
371
guests_can_invite_others=True, # Allow attendees to invite others
372
attendees=[
373
Attendee("instructor@example.com", display_name="Workshop Instructor")
374
]
375
)
376
377
gc.add_event(workshop)
378
```
379
380
### Attendee List Management
381
382
```python
383
from gcsa.google_calendar import GoogleCalendar
384
from gcsa.attendee import Attendee
385
386
gc = GoogleCalendar()
387
388
# Get event and manage attendees
389
event = gc.get_event("event_id")
390
391
# Remove specific attendee
392
event.attendees = [
393
attendee for attendee in event.attendees
394
if attendee.email != "person.to.remove@example.com"
395
]
396
397
# Add attendees based on conditions
398
new_attendees = []
399
if len(event.attendees) < 5: # Only add if not too crowded
400
new_attendees.extend([
401
Attendee("backup1@example.com", optional=True),
402
Attendee("backup2@example.com", optional=True)
403
])
404
405
event.add_attendees(new_attendees)
406
gc.update_event(event)
407
```
408
409
### Organizer and Creator Information
410
411
```python
412
from gcsa.google_calendar import GoogleCalendar
413
from gcsa.person import Person
414
415
gc = GoogleCalendar()
416
417
# Get event and check organizer/creator info
418
event = gc.get_event("event_id")
419
420
# Check who created the event
421
if hasattr(event, 'creator') and event.creator:
422
print(f"Event created by: {event.creator.display_name or event.creator.email}")
423
424
# Check who organizes the event
425
if hasattr(event, 'organizer') and event.organizer:
426
print(f"Event organized by: {event.organizer.display_name or event.organizer.email}")
427
428
# Check if current user is the organizer
429
if hasattr(event.organizer, '_is_self') and event.organizer._is_self:
430
print("You are the organizer of this event")
431
```
432
433
### Attendee Validation and Error Handling
434
435
```python
436
from gcsa.google_calendar import GoogleCalendar
437
from gcsa.attendee import Attendee
438
from gcsa.event import Event
439
from googleapiclient.errors import HttpError
440
from datetime import datetime
441
442
gc = GoogleCalendar()
443
444
try:
445
# Create event with potentially invalid attendee
446
event = Event(
447
summary="Test Meeting",
448
start=datetime(2024, 2, 15, 10, 0),
449
end=datetime(2024, 2, 15, 11, 0),
450
attendees=[
451
Attendee("valid@example.com", display_name="Valid User"),
452
Attendee("invalid-email", display_name="Invalid Email") # Invalid email
453
]
454
)
455
gc.add_event(event)
456
except HttpError as e:
457
print(f"Error adding attendees: {e}")
458
except ValueError as e:
459
print(f"Validation error: {e}")
460
461
# Validate email format before creating attendee
462
import re
463
464
def is_valid_email(email):
465
pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
466
return re.match(pattern, email) is not None
467
468
attendee_emails = ["user@example.com", "invalid-email", "user2@example.com"]
469
valid_attendees = []
470
471
for email in attendee_emails:
472
if is_valid_email(email):
473
valid_attendees.append(Attendee(email))
474
else:
475
print(f"Skipping invalid email: {email}")
476
477
event = Event(
478
summary="Validated Meeting",
479
start=datetime(2024, 2, 15, 10, 0),
480
end=datetime(2024, 2, 15, 11, 0),
481
attendees=valid_attendees
482
)
483
gc.add_event(event)
484
```
485
486
The Attendee and Person classes provide comprehensive support for managing event participants, from simple meetings to complex events with resources, external attendees, and sophisticated permission settings. The classes handle all aspects of attendee management including RSVP tracking, guest permissions, and participant metadata.