dominus-sdk-python-dev 2.1.6__py3-none-any.whl → 2.1.7__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.
@@ -1,93 +1,93 @@
1
- """Sovereign Cloud service handler - Uses Bridge API"""
2
- from ..helpers.core import execute_bridge_call, execute_with_retry, DominusResponse
3
-
4
- # Bridge method map: command → (bridge_method, cacheable)
5
- # All secrets/project operations go through the Bridge API at /newapi/bridge
6
- # Auth operations (auth.self, auth.mint, auth.jwks) are handled separately via /newapi/auth
7
- BRIDGE_METHODS = {
8
- # Secrets (via Bridge API)
9
- "secrets.get": ("secrets.get", True),
10
- "secrets.upsert": ("secrets.upsert", False),
11
- }
12
-
13
- # Legacy routes for non-bridge endpoints
14
- LEGACY_ROUTES = {
15
- # Health (public, no auth needed)
16
- "sovereign.health.ping": ("GET", "/health", False, False),
17
- "sovereign.health.ready": ("GET", "/health/ready", False, False),
18
-
19
- # Project info - TODO: migrate to Bridge API
20
- "project.info": ("POST", "/api/project/info", True, True),
21
- }
22
-
23
-
24
- async def handle(command: str, token: str, sovereign_url: str, **kwargs) -> DominusResponse:
25
- """
26
- Handle Sovereign Cloud command.
27
-
28
- Uses Bridge API for secrets operations (JWT authenticated).
29
- Uses Crossover API for cross-project operations (JWT authenticated, admin scope).
30
- Falls back to legacy routes for health checks and project info.
31
-
32
- Args:
33
- command: Command name (e.g., "secrets.get", "crossover.secrets.get")
34
- token: PSK auth token (DOMINUS_TOKEN, used to get JWT)
35
- sovereign_url: Sovereign base URL
36
- **kwargs: Command parameters
37
-
38
- Returns:
39
- Response dict
40
-
41
- Raises:
42
- ValueError: If command is unknown or missing required parameters
43
- RuntimeError: If auth token is missing
44
- """
45
- # Check for crossover prefix
46
- if command.startswith("crossover."):
47
- # Extract method name (remove "crossover." prefix)
48
- method = command[10:] # len("crossover.") = 10
49
-
50
- # Validate required parameters
51
- if "project_slug" not in kwargs:
52
- raise ValueError("crossover commands require 'project_slug' parameter")
53
- if "environment" not in kwargs:
54
- raise ValueError("crossover commands require 'environment' parameter")
55
-
56
- # Check if method is in BRIDGE_METHODS
57
- if method not in BRIDGE_METHODS:
58
- raise ValueError(f"Unknown crossover method: {method}. Available: {list(BRIDGE_METHODS.keys())}")
59
-
60
- bridge_method, cacheable = BRIDGE_METHODS[method]
61
- return await execute_bridge_call(
62
- method=bridge_method,
63
- base_url=sovereign_url,
64
- token=token,
65
- params=kwargs,
66
- cacheable=cacheable,
67
- endpoint="/newapi/crossover"
68
- )
69
-
70
- # Check Bridge API methods (own-project operations)
71
- if command in BRIDGE_METHODS:
72
- bridge_method, cacheable = BRIDGE_METHODS[command]
73
- return await execute_bridge_call(
74
- method=bridge_method,
75
- base_url=sovereign_url,
76
- token=token,
77
- params=kwargs,
78
- cacheable=cacheable
79
- )
80
-
81
- # Fall back to legacy routes
82
- if command in LEGACY_ROUTES:
83
- route_info = LEGACY_ROUTES[command]
84
- return await execute_with_retry(route_info, sovereign_url, token, kwargs)
85
-
86
- # Unknown command
87
- all_commands = list(BRIDGE_METHODS.keys()) + list(LEGACY_ROUTES.keys())
88
- crossover_commands = [f"crossover.{cmd}" for cmd in BRIDGE_METHODS.keys()]
89
- all_commands.extend(crossover_commands)
90
- raise ValueError(
91
- f"Unknown command: {command}. "
92
- f"Available: {all_commands}"
93
- )
1
+ """Sovereign Cloud service handler - Uses Bridge API"""
2
+ from ..helpers.core import execute_bridge_call, execute_with_retry, DominusResponse
3
+
4
+ # Bridge method map: command → (bridge_method, cacheable)
5
+ # All secrets/project operations go through the Bridge API at /newapi/bridge
6
+ # Auth operations (auth.self, auth.mint, auth.jwks) are handled separately via /newapi/auth
7
+ BRIDGE_METHODS = {
8
+ # Secrets (via Bridge API)
9
+ "secrets.get": ("secrets.get", True),
10
+ "secrets.upsert": ("secrets.upsert", False),
11
+ }
12
+
13
+ # Legacy routes for non-bridge endpoints
14
+ LEGACY_ROUTES = {
15
+ # Health (public, no auth needed)
16
+ "sovereign.health.ping": ("GET", "/health", False, False),
17
+ "sovereign.health.ready": ("GET", "/health/ready", False, False),
18
+
19
+ # Project info - TODO: migrate to Bridge API
20
+ "project.info": ("POST", "/api/project/info", True, True),
21
+ }
22
+
23
+
24
+ async def handle(command: str, token: str, sovereign_url: str, **kwargs) -> DominusResponse:
25
+ """
26
+ Handle Sovereign Cloud command.
27
+
28
+ Uses Bridge API for secrets operations (JWT authenticated).
29
+ Uses Crossover API for cross-project operations (JWT authenticated, admin scope).
30
+ Falls back to legacy routes for health checks and project info.
31
+
32
+ Args:
33
+ command: Command name (e.g., "secrets.get", "crossover.secrets.get")
34
+ token: PSK auth token (DOMINUS_TOKEN, used to get JWT)
35
+ sovereign_url: Sovereign base URL
36
+ **kwargs: Command parameters
37
+
38
+ Returns:
39
+ Response dict
40
+
41
+ Raises:
42
+ ValueError: If command is unknown or missing required parameters
43
+ RuntimeError: If auth token is missing
44
+ """
45
+ # Check for crossover prefix
46
+ if command.startswith("crossover."):
47
+ # Extract method name (remove "crossover." prefix)
48
+ method = command[10:] # len("crossover.") = 10
49
+
50
+ # Validate required parameters
51
+ if "project_slug" not in kwargs:
52
+ raise ValueError("crossover commands require 'project_slug' parameter")
53
+ if "environment" not in kwargs:
54
+ raise ValueError("crossover commands require 'environment' parameter")
55
+
56
+ # Check if method is in BRIDGE_METHODS
57
+ if method not in BRIDGE_METHODS:
58
+ raise ValueError(f"Unknown crossover method: {method}. Available: {list(BRIDGE_METHODS.keys())}")
59
+
60
+ bridge_method, cacheable = BRIDGE_METHODS[method]
61
+ return await execute_bridge_call(
62
+ method=bridge_method,
63
+ base_url=sovereign_url,
64
+ token=token,
65
+ params=kwargs,
66
+ cacheable=cacheable,
67
+ endpoint="/newapi/crossover"
68
+ )
69
+
70
+ # Check Bridge API methods (own-project operations)
71
+ if command in BRIDGE_METHODS:
72
+ bridge_method, cacheable = BRIDGE_METHODS[command]
73
+ return await execute_bridge_call(
74
+ method=bridge_method,
75
+ base_url=sovereign_url,
76
+ token=token,
77
+ params=kwargs,
78
+ cacheable=cacheable
79
+ )
80
+
81
+ # Fall back to legacy routes
82
+ if command in LEGACY_ROUTES:
83
+ route_info = LEGACY_ROUTES[command]
84
+ return await execute_with_retry(route_info, sovereign_url, token, kwargs)
85
+
86
+ # Unknown command
87
+ all_commands = list(BRIDGE_METHODS.keys()) + list(LEGACY_ROUTES.keys())
88
+ crossover_commands = [f"crossover.{cmd}" for cmd in BRIDGE_METHODS.keys()]
89
+ all_commands.extend(crossover_commands)
90
+ raise ValueError(
91
+ f"Unknown command: {command}. "
92
+ f"Available: {all_commands}"
93
+ )