permiscope 2.2.0__tar.gz → 2.2.2__tar.gz
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.
- {permiscope-2.2.0 → permiscope-2.2.2}/PKG-INFO +7 -3
- {permiscope-2.2.0 → permiscope-2.2.2}/README.md +6 -2
- {permiscope-2.2.0 → permiscope-2.2.2}/permiscope/__init__.py +19 -3
- {permiscope-2.2.0 → permiscope-2.2.2}/permiscope.egg-info/PKG-INFO +7 -3
- {permiscope-2.2.0 → permiscope-2.2.2}/pyproject.toml +1 -1
- {permiscope-2.2.0 → permiscope-2.2.2}/permiscope.egg-info/SOURCES.txt +0 -0
- {permiscope-2.2.0 → permiscope-2.2.2}/permiscope.egg-info/dependency_links.txt +0 -0
- {permiscope-2.2.0 → permiscope-2.2.2}/permiscope.egg-info/top_level.txt +0 -0
- {permiscope-2.2.0 → permiscope-2.2.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: permiscope
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.2
|
|
4
4
|
Summary: Dependency-free Python client for the Permiscope governance sidecar
|
|
5
5
|
Author: Shubham Sharma
|
|
6
6
|
License-Expression: MIT
|
|
@@ -46,8 +46,12 @@ decision = scope.decide("run_command", {"command": "echo hello"})
|
|
|
46
46
|
if scope.allowed("read_file", {"path": "config.json"}):
|
|
47
47
|
...
|
|
48
48
|
|
|
49
|
-
result = scope.execute(
|
|
50
|
-
|
|
49
|
+
result = scope.execute(
|
|
50
|
+
"run_command",
|
|
51
|
+
{"command": "echo governed"},
|
|
52
|
+
idempotency_key="operation-1",
|
|
53
|
+
)
|
|
54
|
+
print(result["decision"], result["success"], result.get("outcome"))
|
|
51
55
|
```
|
|
52
56
|
|
|
53
57
|
Run the complete example from a checkout with
|
|
@@ -34,8 +34,12 @@ decision = scope.decide("run_command", {"command": "echo hello"})
|
|
|
34
34
|
if scope.allowed("read_file", {"path": "config.json"}):
|
|
35
35
|
...
|
|
36
36
|
|
|
37
|
-
result = scope.execute(
|
|
38
|
-
|
|
37
|
+
result = scope.execute(
|
|
38
|
+
"run_command",
|
|
39
|
+
{"command": "echo governed"},
|
|
40
|
+
idempotency_key="operation-1",
|
|
41
|
+
)
|
|
42
|
+
print(result["decision"], result["success"], result.get("outcome"))
|
|
39
43
|
```
|
|
40
44
|
|
|
41
45
|
Run the complete example from a checkout with
|
|
@@ -43,9 +43,19 @@ class Permiscope:
|
|
|
43
43
|
action_name: str,
|
|
44
44
|
parameters: Optional[Dict[str, Any]] = None,
|
|
45
45
|
reason: Optional[str] = None,
|
|
46
|
+
idempotency_key: Optional[str] = None,
|
|
46
47
|
) -> Dict[str, Any]:
|
|
47
|
-
"""Ask the sidecar to govern and execute a built-in action.
|
|
48
|
-
|
|
48
|
+
"""Ask the sidecar to govern and execute a built-in action.
|
|
49
|
+
|
|
50
|
+
``idempotency_key`` binds a retry to the same request contents. Reusing
|
|
51
|
+
the key for a different action or parameters returns HTTP 409.
|
|
52
|
+
"""
|
|
53
|
+
headers = {"Idempotency-Key": idempotency_key} if idempotency_key else None
|
|
54
|
+
return self._post(
|
|
55
|
+
"/v1/execute",
|
|
56
|
+
self._payload(action_name, parameters, reason),
|
|
57
|
+
headers=headers,
|
|
58
|
+
)
|
|
49
59
|
|
|
50
60
|
def allowed(
|
|
51
61
|
self,
|
|
@@ -69,13 +79,19 @@ class Permiscope:
|
|
|
69
79
|
payload["reason"] = reason
|
|
70
80
|
return payload
|
|
71
81
|
|
|
72
|
-
def _post(
|
|
82
|
+
def _post(
|
|
83
|
+
self,
|
|
84
|
+
path: str,
|
|
85
|
+
payload: Dict[str, Any],
|
|
86
|
+
headers: Optional[Dict[str, str]] = None,
|
|
87
|
+
) -> Dict[str, Any]:
|
|
73
88
|
request = urllib.request.Request(
|
|
74
89
|
self.base_url + path,
|
|
75
90
|
data=json.dumps(payload).encode("utf-8"),
|
|
76
91
|
headers={
|
|
77
92
|
"Content-Type": "application/json",
|
|
78
93
|
"Authorization": f"Bearer {self.token}",
|
|
94
|
+
**(headers or {}),
|
|
79
95
|
},
|
|
80
96
|
method="POST",
|
|
81
97
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: permiscope
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.2
|
|
4
4
|
Summary: Dependency-free Python client for the Permiscope governance sidecar
|
|
5
5
|
Author: Shubham Sharma
|
|
6
6
|
License-Expression: MIT
|
|
@@ -46,8 +46,12 @@ decision = scope.decide("run_command", {"command": "echo hello"})
|
|
|
46
46
|
if scope.allowed("read_file", {"path": "config.json"}):
|
|
47
47
|
...
|
|
48
48
|
|
|
49
|
-
result = scope.execute(
|
|
50
|
-
|
|
49
|
+
result = scope.execute(
|
|
50
|
+
"run_command",
|
|
51
|
+
{"command": "echo governed"},
|
|
52
|
+
idempotency_key="operation-1",
|
|
53
|
+
)
|
|
54
|
+
print(result["decision"], result["success"], result.get("outcome"))
|
|
51
55
|
```
|
|
52
56
|
|
|
53
57
|
Run the complete example from a checkout with
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|