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/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""CLI command modules for Google Workspace services."""
|
gws/commands/_account.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""Shared Typer callback for --account flag."""
|
|
2
|
+
|
|
3
|
+
from typing import Annotated, Optional
|
|
4
|
+
|
|
5
|
+
import typer
|
|
6
|
+
|
|
7
|
+
from gws.config import Config
|
|
8
|
+
from gws.context import set_active_account
|
|
9
|
+
from gws.exceptions import AuthError, ExitCode
|
|
10
|
+
from gws.output import output_error
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def account_callback(
|
|
14
|
+
ctx: typer.Context,
|
|
15
|
+
account: Annotated[
|
|
16
|
+
Optional[str],
|
|
17
|
+
typer.Option(
|
|
18
|
+
"--account",
|
|
19
|
+
"-a",
|
|
20
|
+
envvar="GWS_ACCOUNT",
|
|
21
|
+
help="Named account to use (overrides default).",
|
|
22
|
+
),
|
|
23
|
+
] = None,
|
|
24
|
+
) -> None:
|
|
25
|
+
"""Resolve and set the active account for this command invocation."""
|
|
26
|
+
config = Config.load()
|
|
27
|
+
try:
|
|
28
|
+
resolved = config.resolve_account(account)
|
|
29
|
+
except AuthError as e:
|
|
30
|
+
output_error(
|
|
31
|
+
error_code="INVALID_ARGS",
|
|
32
|
+
operation="account",
|
|
33
|
+
message=str(e),
|
|
34
|
+
)
|
|
35
|
+
raise typer.Exit(ExitCode.INVALID_ARGS)
|
|
36
|
+
set_active_account(resolved)
|
|
37
|
+
|
|
38
|
+
# Enforce allowed_operations from per-account config
|
|
39
|
+
if resolved:
|
|
40
|
+
overrides = config.load_account_config(resolved)
|
|
41
|
+
allowed = overrides.get("allowed_operations")
|
|
42
|
+
if allowed is not None:
|
|
43
|
+
service = ctx.info_name
|
|
44
|
+
command = ctx.invoked_subcommand
|
|
45
|
+
if command and (service not in allowed or command not in allowed[service]):
|
|
46
|
+
allowed_cmds = allowed.get(service, [])
|
|
47
|
+
output_error(
|
|
48
|
+
error_code="OPERATION_NOT_ALLOWED",
|
|
49
|
+
operation=f"{service}.{command}",
|
|
50
|
+
message=(
|
|
51
|
+
f"Operation '{command}' is not allowed for account '{resolved}'."
|
|
52
|
+
+ (f" Allowed: {', '.join(allowed_cmds)}" if allowed_cmds else "")
|
|
53
|
+
),
|
|
54
|
+
)
|
|
55
|
+
raise typer.Exit(ExitCode.INVALID_ARGS)
|