opa-python-client 2.0.1__tar.gz → 2.0.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.
- {opa_python_client-2.0.1 → opa_python_client-2.0.2}/PKG-INFO +1 -1
- {opa_python_client-2.0.1 → opa_python_client-2.0.2}/opa_client/__init__.py +1 -1
- {opa_python_client-2.0.1 → opa_python_client-2.0.2}/opa_client/opa.py +13 -14
- {opa_python_client-2.0.1 → opa_python_client-2.0.2}/pyproject.toml +1 -1
- {opa_python_client-2.0.1 → opa_python_client-2.0.2}/LICENCE.md +0 -0
- {opa_python_client-2.0.1 → opa_python_client-2.0.2}/README.md +0 -0
- {opa_python_client-2.0.1 → opa_python_client-2.0.2}/opa_client/base.py +0 -0
- {opa_python_client-2.0.1 → opa_python_client-2.0.2}/opa_client/errors.py +0 -0
- {opa_python_client-2.0.1 → opa_python_client-2.0.2}/opa_client/opa_async.py +0 -0
- {opa_python_client-2.0.1 → opa_python_client-2.0.2}/opa_client/test/__init__.py +0 -0
- {opa_python_client-2.0.1 → opa_python_client-2.0.2}/opa_client/test/test_async_client.py +0 -0
- {opa_python_client-2.0.1 → opa_python_client-2.0.2}/opa_client/test/test_integaration_opa.py +0 -0
- {opa_python_client-2.0.1 → opa_python_client-2.0.2}/opa_client/test/test_opa.py +0 -0
- {opa_python_client-2.0.1 → opa_python_client-2.0.2}/opa_client/test/test_opa_client.py +0 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import json
|
|
2
1
|
import os
|
|
3
2
|
import threading
|
|
4
3
|
from typing import Dict, Optional
|
|
@@ -10,15 +9,15 @@ from urllib3.util.retry import Retry
|
|
|
10
9
|
|
|
11
10
|
from .base import BaseClient
|
|
12
11
|
from .errors import (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
CheckPermissionError,
|
|
13
|
+
ConnectionsError,
|
|
14
|
+
DeleteDataError,
|
|
15
|
+
DeletePolicyError,
|
|
16
|
+
FileError,
|
|
17
|
+
PathNotFoundError,
|
|
18
|
+
PolicyNotFoundError,
|
|
19
|
+
RegoParseError,
|
|
20
|
+
TypeException,
|
|
22
21
|
)
|
|
23
22
|
|
|
24
23
|
|
|
@@ -202,7 +201,7 @@ class OpaClient(BaseClient):
|
|
|
202
201
|
bool: True if the policy was successfully updated.
|
|
203
202
|
"""
|
|
204
203
|
if not os.path.isfile(filepath):
|
|
205
|
-
raise FileError(f"'{filepath}' is not a valid file")
|
|
204
|
+
raise FileError("file_not_found",f"'{filepath}' is not a valid file")
|
|
206
205
|
|
|
207
206
|
with open(filepath, "r", encoding="utf-8") as file:
|
|
208
207
|
policy_str = file.read()
|
|
@@ -300,7 +299,7 @@ class OpaClient(BaseClient):
|
|
|
300
299
|
policy_raw = policy.get("result", {}).get("raw", "")
|
|
301
300
|
|
|
302
301
|
if not policy_raw:
|
|
303
|
-
raise PolicyNotFoundError("Policy content is empty")
|
|
302
|
+
raise PolicyNotFoundError("resource_not_found", "Policy content is empty")
|
|
304
303
|
|
|
305
304
|
full_path = os.path.join(path or "", filename)
|
|
306
305
|
|
|
@@ -309,7 +308,7 @@ class OpaClient(BaseClient):
|
|
|
309
308
|
file.write(policy_raw)
|
|
310
309
|
return True
|
|
311
310
|
except OSError as e:
|
|
312
|
-
raise PathNotFoundError(f"Failed to write to '{full_path}'") from e
|
|
311
|
+
raise PathNotFoundError("path_not_found", f"Failed to write to '{full_path}'") from e
|
|
313
312
|
|
|
314
313
|
def get_policy(self, policy_name: str) -> dict:
|
|
315
314
|
"""
|
|
@@ -395,7 +394,7 @@ class OpaClient(BaseClient):
|
|
|
395
394
|
|
|
396
395
|
if rule_name not in rules:
|
|
397
396
|
raise CheckPermissionError(
|
|
398
|
-
f"Rule '{rule_name}' not found in policy '{policy_name}'"
|
|
397
|
+
"resource_not_found", f"Rule '{rule_name}' not found in policy '{policy_name}'"
|
|
399
398
|
)
|
|
400
399
|
|
|
401
400
|
url = f"{self.root_url}/{package_path}/{rule_name}"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opa_python_client-2.0.1 → opa_python_client-2.0.2}/opa_client/test/test_integaration_opa.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|