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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: opa-python-client
3
- Version: 2.0.1
3
+ Version: 2.0.2
4
4
  Summary: Client for connection to the OPA service
5
5
  Home-page: https://github.com/Turall/OPA-python-client
6
6
  License: MIT
@@ -11,7 +11,7 @@ def create_opa_client(async_mode=False, *args, **kwargs):
11
11
  return OpaClient(*args, **kwargs)
12
12
 
13
13
 
14
- __version__ = "2.0.1"
14
+ __version__ = "2.0.2"
15
15
  __author__ = "Tural Muradov"
16
16
  __license__ = "MIT"
17
17
 
@@ -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
- CheckPermissionError,
14
- ConnectionsError,
15
- DeleteDataError,
16
- DeletePolicyError,
17
- FileError,
18
- PathNotFoundError,
19
- PolicyNotFoundError,
20
- RegoParseError,
21
- TypeException,
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}"
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "opa-python-client"
3
- version = "2.0.1"
3
+ version = "2.0.2"
4
4
  description = "Client for connection to the OPA service"
5
5
  authors = ["Tural Muradov <tural.muradoov@gmail.com>"]
6
6
  license = "MIT"