gsuite-sdk 0.1.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.
@@ -0,0 +1,384 @@
1
+ Metadata-Version: 2.4
2
+ Name: gsuite-sdk
3
+ Version: 0.1.0
4
+ Summary: Unified Google Workspace SDK - Gmail, Calendar, Drive, Sheets
5
+ Author-email: Pablo Alaniz <alanizpablo@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/PabloAlaniz/google-suite
8
+ Project-URL: Repository, https://github.com/PabloAlaniz/google-suite
9
+ Project-URL: Documentation, https://github.com/PabloAlaniz/google-suite#readme
10
+ Keywords: google,workspace,gmail,calendar,drive,sheets,oauth,api
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Requires-Python: >=3.11
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: google-auth>=2.27.0
21
+ Requires-Dist: google-auth-oauthlib>=1.2.0
22
+ Requires-Dist: google-api-python-client>=2.114.0
23
+ Requires-Dist: pydantic>=2.5.0
24
+ Requires-Dist: pydantic-settings>=2.1.0
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=7.4.0; extra == "dev"
27
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
28
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
29
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
30
+ Requires-Dist: mypy>=1.8.0; extra == "dev"
31
+ Provides-Extra: cloudrun
32
+ Requires-Dist: google-cloud-secret-manager>=2.18.0; extra == "cloudrun"
33
+ Provides-Extra: all
34
+ Requires-Dist: fastapi>=0.109.0; extra == "all"
35
+ Requires-Dist: uvicorn>=0.27.0; extra == "all"
36
+ Requires-Dist: typer>=0.9.0; extra == "all"
37
+ Requires-Dist: rich>=13.7.0; extra == "all"
38
+ Dynamic: license-file
39
+
40
+ # Google Suite
41
+
42
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
43
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
44
+
45
+ Unified Python SDK for Google Workspace APIs with Clean Architecture.
46
+
47
+ ## Features
48
+
49
+ - 🔐 **Unified Auth** - Single OAuth flow for all Google APIs
50
+ - 📧 **Gmail** - Send, receive, search, labels, attachments
51
+ - 📅 **Calendar** - Events, calendars, scheduling
52
+ - 📁 **Drive** - Files, folders, sharing, upload/download
53
+ - 📊 **Sheets** - Read, write, append, format, batch operations
54
+ - 🚀 **REST API** - Single FastAPI gateway for all services
55
+ - 💻 **CLI** - Unified command-line interface
56
+
57
+ ## Installation
58
+
59
+ ```bash
60
+ pip install gsuite-sdk
61
+ ```
62
+
63
+ Optional extras:
64
+ ```bash
65
+ pip install gsuite-sdk[cloudrun] # Google Cloud Secret Manager support
66
+ pip install gsuite-sdk[all] # All optional dependencies (FastAPI, CLI)
67
+ ```
68
+
69
+ ## Quick Start
70
+
71
+ ### Prerequisites
72
+
73
+ You need OAuth credentials from Google Cloud Console. See [Getting Credentials](docs/GETTING_CREDENTIALS.md) for a step-by-step guide.
74
+
75
+ ### Authentication
76
+
77
+ ```python
78
+ from gsuite_core import GoogleAuth
79
+
80
+ # OAuth (interactive, opens browser)
81
+ auth = GoogleAuth()
82
+ auth.authenticate()
83
+
84
+ # Or with service account
85
+ auth = GoogleAuth.from_service_account("service-account.json")
86
+ ```
87
+
88
+ ### Gmail
89
+
90
+ ```python
91
+ from gsuite_gmail import Gmail, query
92
+
93
+ gmail = Gmail(auth)
94
+
95
+ # Get unread messages with fluent API
96
+ for message in gmail.get_unread():
97
+ print(f"{message.sender}: {message.subject}")
98
+ message.mark_as_read().archive() # Fluent chaining!
99
+
100
+ # Send email with signature
101
+ gmail.send(
102
+ to=["recipient@example.com"],
103
+ subject="Hello",
104
+ body="World",
105
+ signature=True, # Appends your Gmail signature
106
+ )
107
+
108
+ # Search with query builder (inspired by simplegmail)
109
+ messages = gmail.search(
110
+ query.newer_than(days=7) & query.has_attachment() & query.from_("boss@company.com")
111
+ )
112
+
113
+ # Or use construct_query for dict-style
114
+ messages = gmail.search(query.construct_query(
115
+ unread=True,
116
+ newer_than=(7, "day"),
117
+ labels=["Work"],
118
+ ))
119
+ ```
120
+
121
+ ### Drive
122
+
123
+ ```python
124
+ from gsuite_drive import Drive
125
+
126
+ drive = Drive(auth)
127
+
128
+ # List files
129
+ for file in drive.list_files():
130
+ print(f"{file.name} ({file.mime_type})")
131
+
132
+ # Upload
133
+ uploaded = drive.upload("document.pdf")
134
+ print(f"Uploaded: {uploaded.web_view_link}")
135
+
136
+ # Download
137
+ file = drive.get("file_id")
138
+ file.download("local_copy.pdf")
139
+
140
+ # Create folder and upload into it
141
+ folder = drive.create_folder("My Folder")
142
+ drive.upload("file.txt", parent_id=folder.id)
143
+ ```
144
+
145
+ ### Calendar
146
+
147
+ ```python
148
+ from gsuite_calendar import Calendar
149
+
150
+ calendar = Calendar(auth)
151
+
152
+ # Get upcoming events
153
+ events = calendar.get_upcoming(days=7)
154
+ for event in events:
155
+ print(f"{event.start}: {event.summary}")
156
+
157
+ # Create event
158
+ calendar.create_event(
159
+ summary="Meeting",
160
+ start="2026-01-30T10:00:00",
161
+ end="2026-01-30T11:00:00",
162
+ )
163
+ ```
164
+
165
+ ### REST API
166
+
167
+ ```bash
168
+ # Start unified API server
169
+ gsuite serve --port 8080
170
+
171
+ # Or with Docker
172
+ docker run -p 8080:8080 gsuite-api
173
+ ```
174
+
175
+ ```bash
176
+ # All services under one roof
177
+ curl http://localhost:8080/gmail/messages/unread
178
+ curl http://localhost:8080/calendar/events/upcoming
179
+ curl http://localhost:8080/drive/files
180
+ ```
181
+
182
+ **Interactive API docs available at `/docs` when server is running.** See [API Documentation](#api-documentation) section below for details.
183
+
184
+ ### CLI
185
+
186
+ ```bash
187
+ # Authentication
188
+ gsuite auth login # Opens browser for OAuth
189
+ gsuite auth status # Check auth status
190
+ gsuite auth export # Export token for Cloud Run
191
+
192
+ # Gmail
193
+ gsuite gmail list --unread # List unread messages
194
+ gsuite gmail read MSG_ID # Read specific message
195
+ gsuite gmail send --to user@example.com --subject "Hi" --body "Hello"
196
+ gsuite gmail search "from:boss has:attachment"
197
+ gsuite gmail labels # List all labels
198
+
199
+ # Calendar
200
+ gsuite calendar list --days 7 # Upcoming events
201
+ gsuite calendar today # Today's events
202
+ gsuite calendar week # Week view
203
+ gsuite calendar create "Meeting" --start "2026-01-30 10:00"
204
+ gsuite calendar calendars # List calendars
205
+
206
+ # Server
207
+ gsuite serve --port 8080 # Start REST API
208
+ gsuite status # Overall status
209
+ ```
210
+
211
+ ## Architecture
212
+
213
+ ```
214
+ google-suite/
215
+ ├── packages/
216
+ │ ├── core/ # Shared auth, config, token storage
217
+ │ ├── gmail/ # Gmail client + query builder
218
+ │ ├── calendar/ # Calendar client
219
+ │ ├── drive/ # Drive client (upload, download, share)
220
+ │ └── sheets/ # Sheets client (planned)
221
+ ├── api/ # Unified FastAPI REST gateway
222
+ ├── cli/ # Unified CLI (Typer + Rich)
223
+ ├── skill/ # AI agent skill (OpenClaw compatible)
224
+ └── tests/ # Integration tests
225
+ ```
226
+
227
+ ### Design Principles
228
+
229
+ - **Clean Architecture** - Domain entities, interfaces, infrastructure separation
230
+ - **Provider Agnostic** - Swap implementations via interfaces
231
+ - **Shared Auth** - One OAuth flow grants access to all services
232
+ - **Independent Packages** - Install only what you need
233
+ - **Unified Gateway** - Single API/CLI for all services
234
+
235
+ ## AI Agent Skill
236
+
237
+ This repo includes an [OpenClaw](https://openclaw.ai)-compatible skill for AI agents:
238
+
239
+ ```
240
+ skill/
241
+ ├── SKILL.md # Usage documentation for agents
242
+ └── skill.json # Skill metadata
243
+ ```
244
+
245
+ Agents can use this skill to interact with Google Workspace on behalf of users.
246
+
247
+ ## Standalone Repos
248
+
249
+ This monorepo consolidates and extends these standalone projects:
250
+
251
+ - [Gmail-API](https://github.com/PabloAlaniz/Gmail-API) - Standalone Gmail API
252
+ - [Calendar-API](https://github.com/PabloAlaniz/Calendar-API) - Standalone Calendar API
253
+
254
+ The standalone repos remain functional for existing deployments.
255
+
256
+ ## Configuration
257
+
258
+ Environment variables (prefix `GSUITE_`):
259
+
260
+ | Variable | Description |
261
+ |----------|-------------|
262
+ | `GSUITE_CREDENTIALS_FILE` | OAuth credentials JSON path |
263
+ | `GSUITE_TOKEN_STORAGE` | `sqlite` or `secretmanager` |
264
+ | `GSUITE_TOKEN_DB_PATH` | SQLite token database path |
265
+ | `GSUITE_GCP_PROJECT_ID` | GCP project (for Secret Manager) |
266
+ | `GSUITE_API_KEY` | API key for REST endpoints |
267
+
268
+ ## Development
269
+
270
+ ```bash
271
+ # Clone
272
+ git clone https://github.com/PabloAlaniz/google-suite.git
273
+ cd google-suite
274
+
275
+ # Install all packages in dev mode
276
+ pip install -e "packages/core[dev]"
277
+ pip install -e "packages/gmail[dev]"
278
+ pip install -e "packages/calendar[dev]"
279
+ pip install -e "api[dev]"
280
+ pip install -e "cli[dev]"
281
+
282
+ # Run tests
283
+ pytest
284
+
285
+ # Lint
286
+ ruff check packages api cli
287
+ ```
288
+
289
+ ## Deployment
290
+
291
+ ### Cloud Run (GCP)
292
+
293
+ Deploy the REST API to Cloud Run with Secret Manager for token storage:
294
+
295
+ ```bash
296
+ # Build and push Docker image
297
+ gcloud builds submit --tag gcr.io/YOUR_PROJECT/gsuite-api
298
+
299
+ # Deploy to Cloud Run
300
+ gcloud run deploy gsuite-api \
301
+ --image gcr.io/YOUR_PROJECT/gsuite-api \
302
+ --platform managed \
303
+ --region us-central1 \
304
+ --set-env-vars GSUITE_TOKEN_STORAGE=secretmanager \
305
+ --set-env-vars GSUITE_GCP_PROJECT_ID=YOUR_PROJECT \
306
+ --allow-unauthenticated # or use --no-allow-unauthenticated + IAM
307
+ ```
308
+
309
+ **Note:** For Secret Manager token storage, ensure your Cloud Run service account has `secretmanager.versions.access` permission.
310
+
311
+ ### Docker Compose
312
+
313
+ For local development or self-hosted deployment:
314
+
315
+ ```yaml
316
+ version: '3.8'
317
+ services:
318
+ gsuite-api:
319
+ build: .
320
+ ports:
321
+ - "8080:8080"
322
+ environment:
323
+ GSUITE_CREDENTIALS_FILE: /secrets/credentials.json
324
+ GSUITE_TOKEN_DB_PATH: /data/tokens.db
325
+ GSUITE_API_KEY: your-api-key-here
326
+ volumes:
327
+ - ./credentials.json:/secrets/credentials.json:ro
328
+ - ./data:/data
329
+ ```
330
+
331
+ ## API Documentation
332
+
333
+ When running the REST API server, interactive API docs are available at:
334
+
335
+ - **Swagger UI**: `http://localhost:8080/docs`
336
+ - **ReDoc**: `http://localhost:8080/redoc`
337
+
338
+ ## Troubleshooting
339
+
340
+ ### Token refresh failed
341
+
342
+ **Problem:** `TokenRefreshError: Failed to refresh token`
343
+
344
+ **Solution:**
345
+ - Delete the token database: `rm ~/.gsuite/tokens.db` (or your configured path)
346
+ - Re-authenticate: `gsuite auth login`
347
+ - For service accounts, verify the JSON file hasn't expired
348
+
349
+ ### Missing scopes
350
+
351
+ **Problem:** `HttpError 403: Insufficient Permission`
352
+
353
+ **Solution:**
354
+ - Check required scopes in error message
355
+ - Re-authenticate with additional scopes:
356
+ ```bash
357
+ gsuite auth login --scopes gmail.readonly,calendar,drive
358
+ ```
359
+ - Or update `GSUITE_DEFAULT_SCOPES` environment variable
360
+
361
+ ### Credentials not found
362
+
363
+ **Problem:** `CredentialsNotFoundError: OAuth credentials file not found`
364
+
365
+ **Solution:**
366
+ - Download OAuth credentials from [Google Cloud Console](https://console.cloud.google.com/apis/credentials)
367
+ - Save as `credentials.json` in working directory
368
+ - Or set `GSUITE_CREDENTIALS_FILE` environment variable
369
+
370
+ ### Import errors
371
+
372
+ **Problem:** `ModuleNotFoundError: No module named 'gsuite_gmail'`
373
+
374
+ **Solution:**
375
+ - Install the package: `pip install gsuite-gmail`
376
+ - Or for development: `pip install -e "packages/gmail[dev]"`
377
+
378
+ ## License
379
+
380
+ MIT - see [LICENSE](LICENSE)
381
+
382
+ ## Author
383
+
384
+ Pablo Alaniz ([@PabloAlaniz](https://github.com/PabloAlaniz))
@@ -0,0 +1,42 @@
1
+ gsuite_calendar/__init__.py,sha256=bv5jfO0_cCq6Al7trpeE4qAlvghn9zweTYUEZN0g1TI,291
2
+ gsuite_calendar/calendar_entity.py,sha256=banQQ4LpCgwnWmdBh_3cjduDTzp2fmBhsIqjZzU5ybw,755
3
+ gsuite_calendar/client.py,sha256=fQQ6mxpjnIS2a6X6CO3Ff8wTcw8o-R4Ske--gVb-geI,8402
4
+ gsuite_calendar/event.py,sha256=7PnK2WhzeutEk6A93ERZSJ7Hq879_OfJ0RggF9-vJLc,1482
5
+ gsuite_calendar/parser.py,sha256=f5VkMBgDIire8bDauUm1_a0uvgqafwTdIu3QcKRuLWI,3762
6
+ gsuite_calendar/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ gsuite_core/__init__.py,sha256=xPn5DxeRFn7D9bOd7HpMZKyWv6Nyvxz4kDbYQAQX_HE,1469
8
+ gsuite_core/api_utils.py,sha256=NhZ--DI5WVPcyyK54csUgwMlbww-hZDhYYOseUkOvSk,5548
9
+ gsuite_core/config.py,sha256=ESriNwCTQe58YjtkREXQSMAYEUfLOVS048XWn6oMcZQ,2552
10
+ gsuite_core/exceptions.py,sha256=oPStsB50CiPGmazR8g_RgPLWjunaR5NiEawUJ3Zk1c4,3217
11
+ gsuite_core/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ gsuite_core/auth/__init__.py,sha256=KbwMpy8SpSMOsGGuEdNCA90ktkYqVuE_7_8sqsUiGvg,155
13
+ gsuite_core/auth/oauth.py,sha256=pXO7wm-ysGmW29kXxzi8raqE05CrDZizwkfSIr-G3-g,7748
14
+ gsuite_core/auth/scopes.py,sha256=DTw6x1J58eLCHfZXBok7-j0JNJLfrs7L8EuchvxtQ0Q,2587
15
+ gsuite_core/storage/__init__.py,sha256=pTwqi3yBamP30A84_qUpupnkVIuVUtN8skSwMJz7ok0,344
16
+ gsuite_core/storage/base.py,sha256=oP707l7Be9LveNT5N9jQ6DJLw5-ieDH-pOpano8RCkQ,1395
17
+ gsuite_core/storage/secretmanager.py,sha256=xLCYPrplnSrtwBm67PFf33zlMTdbNLhr_BdVsLChGts,4626
18
+ gsuite_core/storage/sqlite.py,sha256=gkHrBnc0heF_k-B5kvgrA9149bqEIHSjDzXxjkm0iFI,2694
19
+ gsuite_drive/__init__.py,sha256=4v_CJa09r3aw3EiGjjNd76d3y5btsxol2jAFNeZlvvw,211
20
+ gsuite_drive/client.py,sha256=ltq7Pk5KG7_OWMfJKKVyv2DdvFw9rhn3YWEehm2L-KA,11333
21
+ gsuite_drive/file.py,sha256=gRzoZQZwyaHhkgt8TrfV0kUhNVLyOXeE-2R8IAThEew,2668
22
+ gsuite_drive/parser.py,sha256=dWD3v03u6x_ks5XFsrzOmbw8m2ob-vFCH9SqcBmR0d0,1969
23
+ gsuite_drive/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
+ gsuite_gmail/__init__.py,sha256=1xCk4i9Ydi6sTNP-wO4LFD2hnVKP-zCS0QNuYG11nm8,345
25
+ gsuite_gmail/client.py,sha256=bR-cQc8UJH-N253HAltLUnbLRSlEZIj8_1eGk7KiD-w,12158
26
+ gsuite_gmail/label.py,sha256=Dc2cFAsR-eII0qgouJAfofwlfjlqFq5_kNAVjP_kUxg,1232
27
+ gsuite_gmail/message.py,sha256=UCmum5DgMKKiB7YEG4zj_q-_qdNt1RFjfBNkdDJ0mZQ,6577
28
+ gsuite_gmail/parser.py,sha256=JeEfNkgpJdJFIQ2LXLrd7Wmr3xl2M7-uFM901o_84v8,4802
29
+ gsuite_gmail/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
+ gsuite_gmail/query.py,sha256=9UHSm6agDbQ-gAJcEd-CG7DucQ83eOMqr-xY2toCzf8,5812
31
+ gsuite_gmail/thread.py,sha256=MiWsKgrtlvBIET3DEwZgEYVl_6L3qPRQfo3iRKYUyJw,1366
32
+ gsuite_sdk-0.1.0.dist-info/licenses/LICENSE,sha256=25xFe8kmZ3TZzs93SbzlDP_OHHkT5lsANRqQ_Ao2A0M,1069
33
+ gsuite_sheets/__init__.py,sha256=llrLdudKQqoVQKhJE5GVMT_ibJr30vdjXZqrNjqQnXU,279
34
+ gsuite_sheets/client.py,sha256=m1PLd0fgTHIJYWnmLldR4SCnAQtEAWs0XeqUu087mqk,10662
35
+ gsuite_sheets/parser.py,sha256=jQcTcfwG6uYnlyXKOE5yv6Oc6nNVrgEs2nck1xLTxOQ,2267
36
+ gsuite_sheets/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
+ gsuite_sheets/spreadsheet.py,sha256=3YFQHEVw2U9KaV-fsBzkXy-mTCygbJA1HZ2edgtxY-U,2674
38
+ gsuite_sheets/worksheet.py,sha256=stD8ZUArs3-h4yYsS_XnjcKBvjUTikz3pLvxOHyET-c,5789
39
+ gsuite_sdk-0.1.0.dist-info/METADATA,sha256=D5yY2KzdCM6tnixIzsV3hiZze5pw05cU70vfyurmMOk,10775
40
+ gsuite_sdk-0.1.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
41
+ gsuite_sdk-0.1.0.dist-info/top_level.txt,sha256=owr7_TnX3SwC7hcmPZ0rmMqvKY16AiyfWf2HTJFf3Gs,68
42
+ gsuite_sdk-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.10.2)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pablo Alaniz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,5 @@
1
+ gsuite_calendar
2
+ gsuite_core
3
+ gsuite_drive
4
+ gsuite_gmail
5
+ gsuite_sheets
@@ -0,0 +1,13 @@
1
+ """Google Suite Sheets - Simple Sheets API client."""
2
+
3
+ __version__ = "0.1.0"
4
+
5
+ from gsuite_sheets.client import Sheets
6
+ from gsuite_sheets.spreadsheet import Spreadsheet
7
+ from gsuite_sheets.worksheet import Worksheet
8
+
9
+ __all__ = [
10
+ "Sheets",
11
+ "Spreadsheet",
12
+ "Worksheet",
13
+ ]