gws-cli 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gws/__init__.py +3 -0
- gws/__main__.py +9 -0
- gws/auth/__init__.py +14 -0
- gws/auth/oauth.py +211 -0
- gws/auth/provider.py +97 -0
- gws/auth/scopes.py +47 -0
- gws/auth/server.py +700 -0
- gws/cli.py +1123 -0
- gws/commands/__init__.py +1 -0
- gws/commands/_account.py +55 -0
- gws/commands/calendar.py +688 -0
- gws/commands/contacts.py +291 -0
- gws/commands/convert.py +122 -0
- gws/commands/docs.py +1432 -0
- gws/commands/drive.py +580 -0
- gws/commands/gmail.py +885 -0
- gws/commands/sheets.py +1550 -0
- gws/commands/slides.py +1107 -0
- gws/config.py +451 -0
- gws/context.py +14 -0
- gws/crypto.py +217 -0
- gws/exceptions.py +58 -0
- gws/output.py +111 -0
- gws/services/__init__.py +1 -0
- gws/services/base.py +47 -0
- gws/services/calendar.py +1377 -0
- gws/services/contacts.py +812 -0
- gws/services/convert.py +879 -0
- gws/services/docs.py +3723 -0
- gws/services/drive.py +1807 -0
- gws/services/gmail.py +2001 -0
- gws/services/sheets.py +3689 -0
- gws/services/slides.py +2845 -0
- gws/utils/__init__.py +1 -0
- gws/utils/colors.py +25 -0
- gws/utils/diagrams.py +220 -0
- gws/utils/retry.py +111 -0
- gws/utils/security.py +23 -0
- gws_cli-1.0.0.dist-info/METADATA +283 -0
- gws_cli-1.0.0.dist-info/RECORD +43 -0
- gws_cli-1.0.0.dist-info/WHEEL +4 -0
- gws_cli-1.0.0.dist-info/entry_points.txt +2 -0
- gws_cli-1.0.0.dist-info/licenses/LICENSE +21 -0
gws/commands/calendar.py
ADDED
|
@@ -0,0 +1,688 @@
|
|
|
1
|
+
"""Calendar CLI commands."""
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
from typing import Annotated, Optional
|
|
5
|
+
|
|
6
|
+
from gws.commands._account import account_callback
|
|
7
|
+
from gws.exceptions import ExitCode
|
|
8
|
+
from gws.output import output_error
|
|
9
|
+
from gws.services.calendar import CalendarService
|
|
10
|
+
|
|
11
|
+
app = typer.Typer(
|
|
12
|
+
name="calendar",
|
|
13
|
+
help="Google Calendar event operations.",
|
|
14
|
+
no_args_is_help=True,
|
|
15
|
+
callback=account_callback,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@app.command("calendars")
|
|
20
|
+
def list_calendars() -> None:
|
|
21
|
+
"""List all accessible calendars."""
|
|
22
|
+
service = CalendarService()
|
|
23
|
+
service.list_calendars()
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@app.command("list")
|
|
27
|
+
def list_events(
|
|
28
|
+
calendar_id: Annotated[
|
|
29
|
+
str,
|
|
30
|
+
typer.Option("--calendar", "-c", help="Calendar ID (default: primary)."),
|
|
31
|
+
] = "primary",
|
|
32
|
+
time_min: Annotated[
|
|
33
|
+
Optional[str],
|
|
34
|
+
typer.Option("--from", help="Start time (ISO 8601 format)."),
|
|
35
|
+
] = None,
|
|
36
|
+
time_max: Annotated[
|
|
37
|
+
Optional[str],
|
|
38
|
+
typer.Option("--to", help="End time (ISO 8601 format)."),
|
|
39
|
+
] = None,
|
|
40
|
+
max_results: Annotated[
|
|
41
|
+
int,
|
|
42
|
+
typer.Option("--max", "-n", help="Maximum events to return."),
|
|
43
|
+
] = 10,
|
|
44
|
+
query: Annotated[
|
|
45
|
+
Optional[str],
|
|
46
|
+
typer.Option("--query", "-q", help="Free text search."),
|
|
47
|
+
] = None,
|
|
48
|
+
) -> None:
|
|
49
|
+
"""List upcoming events."""
|
|
50
|
+
service = CalendarService()
|
|
51
|
+
service.list_events(
|
|
52
|
+
calendar_id=calendar_id,
|
|
53
|
+
time_min=time_min,
|
|
54
|
+
time_max=time_max,
|
|
55
|
+
max_results=max_results,
|
|
56
|
+
query=query,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@app.command("get")
|
|
61
|
+
def get_event(
|
|
62
|
+
event_id: Annotated[str, typer.Argument(help="Event ID.")],
|
|
63
|
+
calendar_id: Annotated[
|
|
64
|
+
str,
|
|
65
|
+
typer.Option("--calendar", "-c", help="Calendar ID (default: primary)."),
|
|
66
|
+
] = "primary",
|
|
67
|
+
) -> None:
|
|
68
|
+
"""Get a specific event by ID."""
|
|
69
|
+
service = CalendarService()
|
|
70
|
+
service.get_event(event_id=event_id, calendar_id=calendar_id)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@app.command("create")
|
|
74
|
+
def create_event(
|
|
75
|
+
summary: Annotated[str, typer.Argument(help="Event title.")],
|
|
76
|
+
start: Annotated[str, typer.Argument(help="Start time (ISO 8601 or YYYY-MM-DD for all-day).")],
|
|
77
|
+
end: Annotated[str, typer.Argument(help="End time (ISO 8601 or YYYY-MM-DD for all-day).")],
|
|
78
|
+
calendar_id: Annotated[
|
|
79
|
+
str,
|
|
80
|
+
typer.Option("--calendar", "-c", help="Calendar ID (default: primary)."),
|
|
81
|
+
] = "primary",
|
|
82
|
+
description: Annotated[
|
|
83
|
+
Optional[str],
|
|
84
|
+
typer.Option("--description", "-d", help="Event description."),
|
|
85
|
+
] = None,
|
|
86
|
+
location: Annotated[
|
|
87
|
+
Optional[str],
|
|
88
|
+
typer.Option("--location", "-l", help="Event location."),
|
|
89
|
+
] = None,
|
|
90
|
+
attendees: Annotated[
|
|
91
|
+
Optional[str],
|
|
92
|
+
typer.Option("--attendees", "-a", help="Comma-separated attendee emails."),
|
|
93
|
+
] = None,
|
|
94
|
+
all_day: Annotated[
|
|
95
|
+
bool,
|
|
96
|
+
typer.Option("--all-day", help="Create as all-day event."),
|
|
97
|
+
] = False,
|
|
98
|
+
) -> None:
|
|
99
|
+
"""Create a new event."""
|
|
100
|
+
attendee_list = attendees.split(",") if attendees else None
|
|
101
|
+
|
|
102
|
+
service = CalendarService()
|
|
103
|
+
service.create_event(
|
|
104
|
+
summary=summary,
|
|
105
|
+
start=start,
|
|
106
|
+
end=end,
|
|
107
|
+
calendar_id=calendar_id,
|
|
108
|
+
description=description,
|
|
109
|
+
location=location,
|
|
110
|
+
attendees=attendee_list,
|
|
111
|
+
all_day=all_day,
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
@app.command("update")
|
|
116
|
+
def update_event(
|
|
117
|
+
event_id: Annotated[str, typer.Argument(help="Event ID to update.")],
|
|
118
|
+
calendar_id: Annotated[
|
|
119
|
+
str,
|
|
120
|
+
typer.Option("--calendar", "-c", help="Calendar ID (default: primary)."),
|
|
121
|
+
] = "primary",
|
|
122
|
+
summary: Annotated[
|
|
123
|
+
Optional[str],
|
|
124
|
+
typer.Option("--summary", "-s", help="New event title."),
|
|
125
|
+
] = None,
|
|
126
|
+
start: Annotated[
|
|
127
|
+
Optional[str],
|
|
128
|
+
typer.Option("--start", help="New start time."),
|
|
129
|
+
] = None,
|
|
130
|
+
end: Annotated[
|
|
131
|
+
Optional[str],
|
|
132
|
+
typer.Option("--end", help="New end time."),
|
|
133
|
+
] = None,
|
|
134
|
+
description: Annotated[
|
|
135
|
+
Optional[str],
|
|
136
|
+
typer.Option("--description", "-d", help="New description."),
|
|
137
|
+
] = None,
|
|
138
|
+
location: Annotated[
|
|
139
|
+
Optional[str],
|
|
140
|
+
typer.Option("--location", "-l", help="New location."),
|
|
141
|
+
] = None,
|
|
142
|
+
) -> None:
|
|
143
|
+
"""Update an existing event."""
|
|
144
|
+
service = CalendarService()
|
|
145
|
+
service.update_event(
|
|
146
|
+
event_id=event_id,
|
|
147
|
+
calendar_id=calendar_id,
|
|
148
|
+
summary=summary,
|
|
149
|
+
start=start,
|
|
150
|
+
end=end,
|
|
151
|
+
description=description,
|
|
152
|
+
location=location,
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
@app.command("delete")
|
|
157
|
+
def delete_event(
|
|
158
|
+
event_id: Annotated[str, typer.Argument(help="Event ID to delete.")],
|
|
159
|
+
calendar_id: Annotated[
|
|
160
|
+
str,
|
|
161
|
+
typer.Option("--calendar", "-c", help="Calendar ID (default: primary)."),
|
|
162
|
+
] = "primary",
|
|
163
|
+
) -> None:
|
|
164
|
+
"""Delete an event."""
|
|
165
|
+
service = CalendarService()
|
|
166
|
+
service.delete_event(event_id=event_id, calendar_id=calendar_id)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
# ===== Recurring Events =====
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
@app.command("create-recurring")
|
|
173
|
+
def create_recurring_event(
|
|
174
|
+
summary: Annotated[str, typer.Argument(help="Event title.")],
|
|
175
|
+
start: Annotated[str, typer.Argument(help="Start time (ISO 8601 format).")],
|
|
176
|
+
end: Annotated[str, typer.Argument(help="End time (ISO 8601 format).")],
|
|
177
|
+
rrule: Annotated[str, typer.Argument(help="RRULE recurrence rule (e.g., 'FREQ=WEEKLY;BYDAY=MO,WE,FR').")],
|
|
178
|
+
calendar_id: Annotated[
|
|
179
|
+
str,
|
|
180
|
+
typer.Option("--calendar", "-c", help="Calendar ID (default: primary)."),
|
|
181
|
+
] = "primary",
|
|
182
|
+
timezone_str: Annotated[
|
|
183
|
+
str,
|
|
184
|
+
typer.Option("--timezone", "-tz", help="Timezone for the event (default: UTC)."),
|
|
185
|
+
] = "UTC",
|
|
186
|
+
description: Annotated[
|
|
187
|
+
Optional[str],
|
|
188
|
+
typer.Option("--description", "-d", help="Event description."),
|
|
189
|
+
] = None,
|
|
190
|
+
location: Annotated[
|
|
191
|
+
Optional[str],
|
|
192
|
+
typer.Option("--location", "-l", help="Event location."),
|
|
193
|
+
] = None,
|
|
194
|
+
attendees: Annotated[
|
|
195
|
+
Optional[str],
|
|
196
|
+
typer.Option("--attendees", "-a", help="Comma-separated attendee emails."),
|
|
197
|
+
] = None,
|
|
198
|
+
) -> None:
|
|
199
|
+
"""Create a recurring event.
|
|
200
|
+
|
|
201
|
+
Common RRULE examples:
|
|
202
|
+
FREQ=DAILY (every day)
|
|
203
|
+
FREQ=WEEKLY;BYDAY=MO,WE,FR (Mon, Wed, Fri)
|
|
204
|
+
FREQ=MONTHLY;BYMONTHDAY=15 (15th of each month)
|
|
205
|
+
FREQ=YEARLY (yearly)
|
|
206
|
+
"""
|
|
207
|
+
attendee_list = [a.strip() for a in attendees.split(",")] if attendees else None
|
|
208
|
+
|
|
209
|
+
service = CalendarService()
|
|
210
|
+
service.create_recurring_event(
|
|
211
|
+
summary=summary,
|
|
212
|
+
start=start,
|
|
213
|
+
end=end,
|
|
214
|
+
rrule=rrule,
|
|
215
|
+
calendar_id=calendar_id,
|
|
216
|
+
timezone_str=timezone_str,
|
|
217
|
+
description=description,
|
|
218
|
+
location=location,
|
|
219
|
+
attendees=attendee_list,
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
@app.command("instances")
|
|
224
|
+
def get_instances(
|
|
225
|
+
event_id: Annotated[str, typer.Argument(help="Recurring event ID.")],
|
|
226
|
+
calendar_id: Annotated[
|
|
227
|
+
str,
|
|
228
|
+
typer.Option("--calendar", "-c", help="Calendar ID (default: primary)."),
|
|
229
|
+
] = "primary",
|
|
230
|
+
time_min: Annotated[
|
|
231
|
+
Optional[str],
|
|
232
|
+
typer.Option("--from", help="Start time (ISO 8601 format)."),
|
|
233
|
+
] = None,
|
|
234
|
+
time_max: Annotated[
|
|
235
|
+
Optional[str],
|
|
236
|
+
typer.Option("--to", help="End time (ISO 8601 format)."),
|
|
237
|
+
] = None,
|
|
238
|
+
max_results: Annotated[
|
|
239
|
+
int,
|
|
240
|
+
typer.Option("--max", "-n", help="Maximum instances to return."),
|
|
241
|
+
] = 25,
|
|
242
|
+
) -> None:
|
|
243
|
+
"""List instances of a recurring event."""
|
|
244
|
+
service = CalendarService()
|
|
245
|
+
service.get_instances(
|
|
246
|
+
event_id=event_id,
|
|
247
|
+
calendar_id=calendar_id,
|
|
248
|
+
time_min=time_min,
|
|
249
|
+
time_max=time_max,
|
|
250
|
+
max_results=max_results,
|
|
251
|
+
)
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
# ===== Attendee Management =====
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
@app.command("add-attendees")
|
|
258
|
+
def add_attendees(
|
|
259
|
+
event_id: Annotated[str, typer.Argument(help="Event ID.")],
|
|
260
|
+
emails: Annotated[str, typer.Argument(help="Comma-separated email addresses to add.")],
|
|
261
|
+
calendar_id: Annotated[
|
|
262
|
+
str,
|
|
263
|
+
typer.Option("--calendar", "-c", help="Calendar ID (default: primary)."),
|
|
264
|
+
] = "primary",
|
|
265
|
+
no_notify: Annotated[
|
|
266
|
+
bool,
|
|
267
|
+
typer.Option("--no-notify", help="Don't send email notifications."),
|
|
268
|
+
] = False,
|
|
269
|
+
) -> None:
|
|
270
|
+
"""Add attendees to an event."""
|
|
271
|
+
email_list = [e.strip() for e in emails.split(",")]
|
|
272
|
+
|
|
273
|
+
service = CalendarService()
|
|
274
|
+
service.add_attendees(
|
|
275
|
+
event_id=event_id,
|
|
276
|
+
emails=email_list,
|
|
277
|
+
calendar_id=calendar_id,
|
|
278
|
+
send_notifications=not no_notify,
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
@app.command("remove-attendees")
|
|
283
|
+
def remove_attendees(
|
|
284
|
+
event_id: Annotated[str, typer.Argument(help="Event ID.")],
|
|
285
|
+
emails: Annotated[str, typer.Argument(help="Comma-separated email addresses to remove.")],
|
|
286
|
+
calendar_id: Annotated[
|
|
287
|
+
str,
|
|
288
|
+
typer.Option("--calendar", "-c", help="Calendar ID (default: primary)."),
|
|
289
|
+
] = "primary",
|
|
290
|
+
no_notify: Annotated[
|
|
291
|
+
bool,
|
|
292
|
+
typer.Option("--no-notify", help="Don't send email notifications."),
|
|
293
|
+
] = False,
|
|
294
|
+
) -> None:
|
|
295
|
+
"""Remove attendees from an event."""
|
|
296
|
+
email_list = [e.strip() for e in emails.split(",")]
|
|
297
|
+
|
|
298
|
+
service = CalendarService()
|
|
299
|
+
service.remove_attendees(
|
|
300
|
+
event_id=event_id,
|
|
301
|
+
emails=email_list,
|
|
302
|
+
calendar_id=calendar_id,
|
|
303
|
+
send_notifications=not no_notify,
|
|
304
|
+
)
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
@app.command("attendees")
|
|
308
|
+
def get_attendees(
|
|
309
|
+
event_id: Annotated[str, typer.Argument(help="Event ID.")],
|
|
310
|
+
calendar_id: Annotated[
|
|
311
|
+
str,
|
|
312
|
+
typer.Option("--calendar", "-c", help="Calendar ID (default: primary)."),
|
|
313
|
+
] = "primary",
|
|
314
|
+
) -> None:
|
|
315
|
+
"""List attendees and their RSVP status for an event."""
|
|
316
|
+
service = CalendarService()
|
|
317
|
+
service.get_attendees(event_id=event_id, calendar_id=calendar_id)
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
@app.command("rsvp")
|
|
321
|
+
def respond_to_event(
|
|
322
|
+
event_id: Annotated[str, typer.Argument(help="Event ID.")],
|
|
323
|
+
response: Annotated[str, typer.Argument(help="Response: accepted, declined, or tentative.")],
|
|
324
|
+
calendar_id: Annotated[
|
|
325
|
+
str,
|
|
326
|
+
typer.Option("--calendar", "-c", help="Calendar ID (default: primary)."),
|
|
327
|
+
] = "primary",
|
|
328
|
+
) -> None:
|
|
329
|
+
"""Respond to an event invitation (RSVP)."""
|
|
330
|
+
service = CalendarService()
|
|
331
|
+
service.respond_to_event(
|
|
332
|
+
event_id=event_id,
|
|
333
|
+
response=response,
|
|
334
|
+
calendar_id=calendar_id,
|
|
335
|
+
)
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
@app.command("quick-add")
|
|
339
|
+
def quick_add(
|
|
340
|
+
text: Annotated[str, typer.Argument(help="Natural language event description.")],
|
|
341
|
+
calendar_id: Annotated[
|
|
342
|
+
str,
|
|
343
|
+
typer.Option("--calendar", "-c", help="Calendar ID (default: primary)."),
|
|
344
|
+
] = "primary",
|
|
345
|
+
) -> None:
|
|
346
|
+
"""Create an event from natural language.
|
|
347
|
+
|
|
348
|
+
Examples:
|
|
349
|
+
"Meeting tomorrow at 3pm"
|
|
350
|
+
"Lunch with Bob on Friday at noon"
|
|
351
|
+
"Team standup every weekday at 9:30am"
|
|
352
|
+
"""
|
|
353
|
+
service = CalendarService()
|
|
354
|
+
service.quick_add(text=text, calendar_id=calendar_id)
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
# ===== Free/Busy =====
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
@app.command("freebusy")
|
|
361
|
+
def get_freebusy(
|
|
362
|
+
time_min: Annotated[str, typer.Argument(help="Start time (ISO 8601 format).")],
|
|
363
|
+
time_max: Annotated[str, typer.Argument(help="End time (ISO 8601 format).")],
|
|
364
|
+
calendar_ids: Annotated[
|
|
365
|
+
Optional[str],
|
|
366
|
+
typer.Option("--calendars", "-c", help="Comma-separated calendar IDs (default: primary)."),
|
|
367
|
+
] = None,
|
|
368
|
+
timezone_str: Annotated[
|
|
369
|
+
str,
|
|
370
|
+
typer.Option("--timezone", "-tz", help="Timezone for the query."),
|
|
371
|
+
] = "UTC",
|
|
372
|
+
) -> None:
|
|
373
|
+
"""Query free/busy information for calendars."""
|
|
374
|
+
cal_ids = [c.strip() for c in calendar_ids.split(",")] if calendar_ids else None
|
|
375
|
+
|
|
376
|
+
service = CalendarService()
|
|
377
|
+
service.get_freebusy(
|
|
378
|
+
time_min=time_min,
|
|
379
|
+
time_max=time_max,
|
|
380
|
+
calendar_ids=cal_ids,
|
|
381
|
+
timezone_str=timezone_str,
|
|
382
|
+
)
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
# ===== Calendar Sharing (ACL) =====
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
@app.command("list-acl")
|
|
389
|
+
def list_acl(
|
|
390
|
+
calendar_id: Annotated[
|
|
391
|
+
str,
|
|
392
|
+
typer.Option("--calendar", "-c", help="Calendar ID (default: primary)."),
|
|
393
|
+
] = "primary",
|
|
394
|
+
) -> None:
|
|
395
|
+
"""List access control rules (who has access to the calendar)."""
|
|
396
|
+
service = CalendarService()
|
|
397
|
+
service.list_acl(calendar_id=calendar_id)
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
@app.command("add-acl")
|
|
401
|
+
def add_acl(
|
|
402
|
+
scope_type: Annotated[str, typer.Argument(help="Scope type (user, group, domain, default).")],
|
|
403
|
+
scope_value: Annotated[str, typer.Argument(help="Email address or domain.")],
|
|
404
|
+
role: Annotated[str, typer.Argument(help="Role (reader, writer, owner, freeBusyReader).")],
|
|
405
|
+
calendar_id: Annotated[
|
|
406
|
+
str,
|
|
407
|
+
typer.Option("--calendar", "-c", help="Calendar ID (default: primary)."),
|
|
408
|
+
] = "primary",
|
|
409
|
+
) -> None:
|
|
410
|
+
"""Add an access control rule to share a calendar."""
|
|
411
|
+
service = CalendarService()
|
|
412
|
+
service.add_acl(
|
|
413
|
+
scope_type=scope_type,
|
|
414
|
+
scope_value=scope_value,
|
|
415
|
+
role=role,
|
|
416
|
+
calendar_id=calendar_id,
|
|
417
|
+
)
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
@app.command("remove-acl")
|
|
421
|
+
def remove_acl(
|
|
422
|
+
rule_id: Annotated[str, typer.Argument(help="ACL rule ID to remove.")],
|
|
423
|
+
calendar_id: Annotated[
|
|
424
|
+
str,
|
|
425
|
+
typer.Option("--calendar", "-c", help="Calendar ID (default: primary)."),
|
|
426
|
+
] = "primary",
|
|
427
|
+
) -> None:
|
|
428
|
+
"""Remove an access control rule from a calendar."""
|
|
429
|
+
service = CalendarService()
|
|
430
|
+
service.remove_acl(rule_id=rule_id, calendar_id=calendar_id)
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
@app.command("update-acl")
|
|
434
|
+
def update_acl(
|
|
435
|
+
rule_id: Annotated[str, typer.Argument(help="ACL rule ID to update.")],
|
|
436
|
+
role: Annotated[str, typer.Argument(help="New role (reader, writer, owner, freeBusyReader).")],
|
|
437
|
+
calendar_id: Annotated[
|
|
438
|
+
str,
|
|
439
|
+
typer.Option("--calendar", "-c", help="Calendar ID (default: primary)."),
|
|
440
|
+
] = "primary",
|
|
441
|
+
) -> None:
|
|
442
|
+
"""Update an access control rule's role."""
|
|
443
|
+
service = CalendarService()
|
|
444
|
+
service.update_acl(rule_id=rule_id, role=role, calendar_id=calendar_id)
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
# ===== Reminders =====
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
@app.command("get-reminders")
|
|
451
|
+
def get_event_reminders(
|
|
452
|
+
event_id: Annotated[str, typer.Argument(help="Event ID.")],
|
|
453
|
+
calendar_id: Annotated[
|
|
454
|
+
str,
|
|
455
|
+
typer.Option("--calendar", "-c", help="Calendar ID (default: primary)."),
|
|
456
|
+
] = "primary",
|
|
457
|
+
) -> None:
|
|
458
|
+
"""Get reminders for an event."""
|
|
459
|
+
service = CalendarService()
|
|
460
|
+
service.get_event_reminders(event_id=event_id, calendar_id=calendar_id)
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
@app.command("set-reminders")
|
|
464
|
+
def set_event_reminders(
|
|
465
|
+
event_id: Annotated[str, typer.Argument(help="Event ID.")],
|
|
466
|
+
reminders: Annotated[
|
|
467
|
+
Optional[str],
|
|
468
|
+
typer.Option(
|
|
469
|
+
"--reminders", "-r",
|
|
470
|
+
help="Comma-separated reminders (format: method:minutes, e.g., 'popup:10,email:60').",
|
|
471
|
+
),
|
|
472
|
+
] = None,
|
|
473
|
+
use_default: Annotated[
|
|
474
|
+
bool,
|
|
475
|
+
typer.Option("--use-default", help="Use calendar's default reminders."),
|
|
476
|
+
] = False,
|
|
477
|
+
calendar_id: Annotated[
|
|
478
|
+
str,
|
|
479
|
+
typer.Option("--calendar", "-c", help="Calendar ID (default: primary)."),
|
|
480
|
+
] = "primary",
|
|
481
|
+
) -> None:
|
|
482
|
+
"""Set reminders for an event.
|
|
483
|
+
|
|
484
|
+
Examples:
|
|
485
|
+
Set a popup 10 minutes before and email 1 hour before:
|
|
486
|
+
gws-cli calendar set-reminders EVENT_ID --reminders "popup:10,email:60"
|
|
487
|
+
|
|
488
|
+
Use calendar's default reminders:
|
|
489
|
+
gws-cli calendar set-reminders EVENT_ID --use-default
|
|
490
|
+
"""
|
|
491
|
+
reminder_list = None
|
|
492
|
+
if reminders and not use_default:
|
|
493
|
+
reminder_list = []
|
|
494
|
+
for r in reminders.split(","):
|
|
495
|
+
parts = r.strip().split(":")
|
|
496
|
+
if len(parts) != 2:
|
|
497
|
+
output_error(
|
|
498
|
+
error_code="INVALID_ARGS",
|
|
499
|
+
operation="calendar.set_reminders",
|
|
500
|
+
message=f"Invalid reminder format: {r.strip()!r}. Expected 'method:minutes' (e.g., 'popup:10').",
|
|
501
|
+
)
|
|
502
|
+
raise typer.Exit(ExitCode.INVALID_ARGS)
|
|
503
|
+
method, minutes = parts
|
|
504
|
+
try:
|
|
505
|
+
minutes_int = int(minutes.strip())
|
|
506
|
+
except ValueError:
|
|
507
|
+
output_error(
|
|
508
|
+
error_code="INVALID_ARGS",
|
|
509
|
+
operation="calendar.set_reminders",
|
|
510
|
+
message=f"Invalid minutes value: {minutes.strip()!r}. Must be an integer.",
|
|
511
|
+
)
|
|
512
|
+
raise typer.Exit(ExitCode.INVALID_ARGS)
|
|
513
|
+
reminder_list.append({
|
|
514
|
+
"method": method.strip(),
|
|
515
|
+
"minutes": minutes_int,
|
|
516
|
+
})
|
|
517
|
+
|
|
518
|
+
service = CalendarService()
|
|
519
|
+
service.set_event_reminders(
|
|
520
|
+
event_id=event_id,
|
|
521
|
+
reminders=reminder_list,
|
|
522
|
+
use_default=use_default,
|
|
523
|
+
calendar_id=calendar_id,
|
|
524
|
+
)
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
@app.command("clear-reminders")
|
|
528
|
+
def clear_event_reminders(
|
|
529
|
+
event_id: Annotated[str, typer.Argument(help="Event ID.")],
|
|
530
|
+
calendar_id: Annotated[
|
|
531
|
+
str,
|
|
532
|
+
typer.Option("--calendar", "-c", help="Calendar ID (default: primary)."),
|
|
533
|
+
] = "primary",
|
|
534
|
+
) -> None:
|
|
535
|
+
"""Remove all reminders from an event."""
|
|
536
|
+
service = CalendarService()
|
|
537
|
+
service.clear_event_reminders(event_id=event_id, calendar_id=calendar_id)
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
@app.command("get-default-reminders")
|
|
541
|
+
def get_default_reminders(
|
|
542
|
+
calendar_id: Annotated[
|
|
543
|
+
str,
|
|
544
|
+
typer.Option("--calendar", "-c", help="Calendar ID (default: primary)."),
|
|
545
|
+
] = "primary",
|
|
546
|
+
) -> None:
|
|
547
|
+
"""Get default reminders for a calendar."""
|
|
548
|
+
service = CalendarService()
|
|
549
|
+
service.get_default_reminders(calendar_id=calendar_id)
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
@app.command("set-default-reminders")
|
|
553
|
+
def set_default_reminders(
|
|
554
|
+
reminders: Annotated[
|
|
555
|
+
str,
|
|
556
|
+
typer.Argument(help="Comma-separated reminders (format: method:minutes, e.g., 'popup:10,email:60')."),
|
|
557
|
+
],
|
|
558
|
+
calendar_id: Annotated[
|
|
559
|
+
str,
|
|
560
|
+
typer.Option("--calendar", "-c", help="Calendar ID (default: primary)."),
|
|
561
|
+
] = "primary",
|
|
562
|
+
) -> None:
|
|
563
|
+
"""Set default reminders for a calendar.
|
|
564
|
+
|
|
565
|
+
Example:
|
|
566
|
+
Set popup 10 minutes and email 30 minutes before as defaults:
|
|
567
|
+
gws-cli calendar set-default-reminders "popup:10,email:30"
|
|
568
|
+
"""
|
|
569
|
+
reminder_list = []
|
|
570
|
+
for r in reminders.split(","):
|
|
571
|
+
parts = r.strip().split(":")
|
|
572
|
+
if len(parts) != 2:
|
|
573
|
+
output_error(
|
|
574
|
+
error_code="INVALID_ARGS",
|
|
575
|
+
operation="calendar.set_default_reminders",
|
|
576
|
+
message=f"Invalid reminder format: {r.strip()!r}. Expected 'method:minutes' (e.g., 'popup:10').",
|
|
577
|
+
)
|
|
578
|
+
raise typer.Exit(ExitCode.INVALID_ARGS)
|
|
579
|
+
method, minutes = parts
|
|
580
|
+
try:
|
|
581
|
+
minutes_int = int(minutes.strip())
|
|
582
|
+
except ValueError:
|
|
583
|
+
output_error(
|
|
584
|
+
error_code="INVALID_ARGS",
|
|
585
|
+
operation="calendar.set_default_reminders",
|
|
586
|
+
message=f"Invalid minutes value: {minutes.strip()!r}. Must be an integer.",
|
|
587
|
+
)
|
|
588
|
+
raise typer.Exit(ExitCode.INVALID_ARGS)
|
|
589
|
+
reminder_list.append({
|
|
590
|
+
"method": method.strip(),
|
|
591
|
+
"minutes": minutes_int,
|
|
592
|
+
})
|
|
593
|
+
|
|
594
|
+
service = CalendarService()
|
|
595
|
+
service.set_default_reminders(reminders=reminder_list, calendar_id=calendar_id)
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
# ===== Calendar Management =====
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
@app.command("create-calendar")
|
|
602
|
+
def create_calendar(
|
|
603
|
+
summary: Annotated[str, typer.Argument(help="Calendar name/title.")],
|
|
604
|
+
description: Annotated[
|
|
605
|
+
Optional[str],
|
|
606
|
+
typer.Option("--description", "-d", help="Calendar description."),
|
|
607
|
+
] = None,
|
|
608
|
+
timezone: Annotated[
|
|
609
|
+
Optional[str],
|
|
610
|
+
typer.Option("--timezone", "-t", help="Timezone (e.g., 'America/New_York')."),
|
|
611
|
+
] = None,
|
|
612
|
+
) -> None:
|
|
613
|
+
"""Create a new calendar."""
|
|
614
|
+
service = CalendarService()
|
|
615
|
+
service.create_calendar(summary=summary, description=description, timezone=timezone)
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
@app.command("delete-calendar")
|
|
619
|
+
def delete_calendar(
|
|
620
|
+
calendar_id: Annotated[str, typer.Argument(help="Calendar ID to delete.")],
|
|
621
|
+
) -> None:
|
|
622
|
+
"""Delete a secondary calendar (cannot delete primary)."""
|
|
623
|
+
service = CalendarService()
|
|
624
|
+
service.delete_calendar(calendar_id=calendar_id)
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
@app.command("clear-calendar")
|
|
628
|
+
def clear_calendar(
|
|
629
|
+
calendar_id: Annotated[
|
|
630
|
+
str,
|
|
631
|
+
typer.Argument(help="Calendar ID to clear (works on primary calendar)."),
|
|
632
|
+
] = "primary",
|
|
633
|
+
) -> None:
|
|
634
|
+
"""Clear all events from a calendar."""
|
|
635
|
+
service = CalendarService()
|
|
636
|
+
service.clear_calendar(calendar_id=calendar_id)
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
# ===== Event Operations (extended) =====
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
@app.command("move-event")
|
|
643
|
+
def move_event(
|
|
644
|
+
event_id: Annotated[str, typer.Argument(help="Event ID to move.")],
|
|
645
|
+
destination_calendar_id: Annotated[str, typer.Argument(help="Destination calendar ID.")],
|
|
646
|
+
source_calendar_id: Annotated[
|
|
647
|
+
str,
|
|
648
|
+
typer.Option("--from", "-f", help="Source calendar ID."),
|
|
649
|
+
] = "primary",
|
|
650
|
+
) -> None:
|
|
651
|
+
"""Move an event to a different calendar."""
|
|
652
|
+
service = CalendarService()
|
|
653
|
+
service.move_event(
|
|
654
|
+
event_id=event_id,
|
|
655
|
+
source_calendar_id=source_calendar_id,
|
|
656
|
+
destination_calendar_id=destination_calendar_id,
|
|
657
|
+
)
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
# ===== Colors =====
|
|
661
|
+
|
|
662
|
+
|
|
663
|
+
@app.command("colors")
|
|
664
|
+
def get_colors() -> None:
|
|
665
|
+
"""Get the color definitions for calendars and events."""
|
|
666
|
+
service = CalendarService()
|
|
667
|
+
service.get_colors()
|
|
668
|
+
|
|
669
|
+
|
|
670
|
+
# ===== Calendar Subscriptions =====
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
@app.command("subscribe")
|
|
674
|
+
def subscribe_calendar(
|
|
675
|
+
calendar_id: Annotated[str, typer.Argument(help="Calendar ID to subscribe to.")],
|
|
676
|
+
) -> None:
|
|
677
|
+
"""Subscribe to (add) a public calendar to your calendar list."""
|
|
678
|
+
service = CalendarService()
|
|
679
|
+
service.subscribe_calendar(calendar_id=calendar_id)
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
@app.command("unsubscribe")
|
|
683
|
+
def unsubscribe_calendar(
|
|
684
|
+
calendar_id: Annotated[str, typer.Argument(help="Calendar ID to unsubscribe from.")],
|
|
685
|
+
) -> None:
|
|
686
|
+
"""Unsubscribe from (remove) a calendar from your calendar list."""
|
|
687
|
+
service = CalendarService()
|
|
688
|
+
service.unsubscribe_calendar(calendar_id=calendar_id)
|