automizor 0.4.8__py3-none-any.whl → 0.4.10__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.
automizor/__init__.py CHANGED
@@ -1 +1 @@
1
- version = "0.4.8"
1
+ version = "0.4.10"
@@ -10,27 +10,21 @@ class DataStore:
10
10
  to manage and manipulate data stored in various formats. It supports
11
11
  operations to retrieve and update data using a unified API.
12
12
 
13
- The class initializes an HTTP session with the necessary headers for
13
+ The class initializes an HTTP request with the necessary headers for
14
14
  authentication, and provides methods to retrieve values, and set values in
15
15
  the store.
16
-
17
- Attributes:
18
- url (str): The base URL for the API endpoint.
19
- token (str): The authentication token for API access.
20
- session (requests.Session): The HTTP session used to make API requests.
21
16
  """
22
17
 
23
18
  _instance = None
24
19
 
20
+ def __init__(self, api_token: str | None = None):
21
+ self.url, self.token = get_api_config(api_token)
22
+ self.headers = get_headers(self.token)
23
+
25
24
  @classmethod
26
25
  def configure(cls, api_token: str | None = None):
27
26
  cls._instance = cls(api_token)
28
27
 
29
- def __init__(self, api_token: str | None = None):
30
- self.url, self.token = get_api_config(api_token)
31
- self.session = requests.Session()
32
- self.session.headers.update(get_headers(self.token))
33
-
34
28
  @classmethod
35
29
  def get_instance(cls):
36
30
  if cls._instance is None:
@@ -81,7 +75,9 @@ class DataStore:
81
75
  )
82
76
  url = f"https://{self.url}/api/v1/workflow/datastore/{name}/values/"
83
77
  try:
84
- response = self.session.get(url, timeout=10, params=params)
78
+ response = requests.get(
79
+ url, headers=self.headers, params=params, timeout=10
80
+ )
85
81
  response.raise_for_status()
86
82
  return response.json()
87
83
  except requests.HTTPError as exc:
@@ -89,16 +85,16 @@ class DataStore:
89
85
  exc.response, "Failed to get datastore values"
90
86
  ) from exc
91
87
  except Exception as exc:
92
- raise AutomizorError("Failed to get datastore values") from exc
88
+ raise AutomizorError(f"Failed to get datastore values: {exc}") from exc
93
89
 
94
90
  def _set_values(self, name: str, values: JSON) -> None:
95
91
  url = f"https://{self.url}/api/v1/workflow/datastore/{name}/values/"
96
92
  try:
97
- response = self.session.post(url, json=values, timeout=10)
93
+ response = requests.post(url, headers=self.headers, json=values, timeout=10)
98
94
  response.raise_for_status()
99
95
  except requests.HTTPError as exc:
100
96
  raise AutomizorError.from_response(
101
97
  exc.response, "Failed to set datastore values"
102
98
  ) from exc
103
99
  except Exception as exc:
104
- raise AutomizorError("Failed to set datastore values") from exc
100
+ raise AutomizorError(f"Failed to set datastore values: {exc}") from exc
automizor/job/_job.py CHANGED
@@ -48,17 +48,16 @@ class Job:
48
48
 
49
49
  _instance = None
50
50
 
51
- @classmethod
52
- def configure(cls, api_token: str | None = None):
53
- cls._instance = cls(api_token)
54
-
55
51
  def __init__(self, api_token: str | None = None):
56
52
  self._context_file = os.getenv("AUTOMIZOR_CONTEXT_FILE", None)
57
53
  self._job_id = os.getenv("AUTOMIZOR_JOB_ID", None)
58
54
 
59
55
  self.url, self.token = get_api_config(api_token)
60
- self.session = requests.Session()
61
- self.session.headers.update(get_headers(self.token))
56
+ self.headers = get_headers(self.token)
57
+
58
+ @classmethod
59
+ def configure(cls, api_token: str | None = None):
60
+ cls._instance = cls(api_token)
62
61
 
63
62
  @classmethod
64
63
  def get_instance(cls):
@@ -129,7 +128,7 @@ class Job:
129
128
  def _read_job_context(self) -> dict:
130
129
  url = f"https://{self.url}/api/v1/rpa/job/{self._job_id}/"
131
130
  try:
132
- response = self.session.get(url, timeout=10)
131
+ response = requests.get(url, headers=self.headers, timeout=10)
133
132
  response.raise_for_status()
134
133
  return response.json().get("context", {})
135
134
  except requests.HTTPError as exc:
@@ -137,4 +136,4 @@ class Job:
137
136
  exc.response, "Failed to get job context"
138
137
  ) from exc
139
138
  except Exception as exc:
140
- raise AutomizorError("Failed to get job context") from exc
139
+ raise AutomizorError(f"Failed to get job context: {exc}") from exc
@@ -50,15 +50,14 @@ class Storage:
50
50
 
51
51
  _instance = None
52
52
 
53
+ def __init__(self, api_token: str | None = None):
54
+ self.url, self.token = get_api_config(api_token)
55
+ self.headers = get_headers(self.token)
56
+
53
57
  @classmethod
54
58
  def configure(cls, api_token: str | None = None):
55
59
  cls._instance = cls(api_token)
56
60
 
57
- def __init__(self, api_token: str | None = None):
58
- self.url, self.token = get_api_config(api_token)
59
- self.session = requests.Session()
60
- self.session.headers.update(get_headers(self.token))
61
-
62
61
  @classmethod
63
62
  def get_instance(cls):
64
63
  if cls._instance is None:
@@ -80,7 +79,7 @@ class Storage:
80
79
 
81
80
  try:
82
81
  while url:
83
- response = self.session.get(url, timeout=10)
82
+ response = requests.get(url, headers=self.headers, timeout=10)
84
83
  response.raise_for_status()
85
84
  data = response.json()
86
85
 
@@ -92,7 +91,7 @@ class Storage:
92
91
  exc.response, "Failed to list assets"
93
92
  ) from exc
94
93
  except Exception as exc:
95
- raise AutomizorError("Failed to list assets") from exc
94
+ raise AutomizorError(f"Failed to list assets: {exc}") from exc
96
95
  return asset_names
97
96
 
98
97
  def delete_asset(self, name: str):
@@ -109,14 +108,14 @@ class Storage:
109
108
 
110
109
  url = f"https://{self.url}/api/v1/storage/asset/{name}/"
111
110
  try:
112
- response = self.session.delete(url, timeout=10)
111
+ response = requests.delete(url, headers=self.headers, timeout=10)
113
112
  response.raise_for_status()
114
113
  except requests.HTTPError as exc:
115
114
  raise AutomizorError.from_response(
116
115
  exc.response, "Failed to delete asset"
117
116
  ) from exc
118
117
  except Exception as exc:
119
- raise AutomizorError("Failed to delete asset") from exc
118
+ raise AutomizorError(f"Failed to delete asset: {exc}") from exc
120
119
 
121
120
  def get_bytes(self, name: str) -> bytes:
122
121
  """
@@ -231,14 +230,16 @@ class Storage:
231
230
  "name": name,
232
231
  }
233
232
  files = {"file": ("text.txt", content, content_type)}
234
- response = self.session.post(url, files=files, data=data, timeout=10)
233
+ response = requests.post(
234
+ url, headers=self.headers, files=files, data=data, timeout=10
235
+ )
235
236
  response.raise_for_status()
236
237
  except requests.HTTPError as exc:
237
238
  raise AutomizorError.from_response(
238
239
  exc.response, "Failed to create asset"
239
240
  ) from exc
240
241
  except Exception as exc:
241
- raise AutomizorError("Failed to create asset") from exc
242
+ raise AutomizorError(f"Failed to create asset: {exc}") from exc
242
243
 
243
244
  def _download_file(self, name: str, mode: str = "content"):
244
245
  url = self._get_asset_url(name)
@@ -260,12 +261,12 @@ class Storage:
260
261
  exc.response, "Failed to download asset"
261
262
  ) from exc
262
263
  except Exception as exc:
263
- raise AutomizorError("Failed to download asset") from exc
264
+ raise AutomizorError(f"Failed to download asset: {exc}") from exc
264
265
 
265
266
  def _get_asset_url(self, name: str) -> str:
266
267
  url = f"https://{self.url}/api/v1/storage/asset/{name}/"
267
268
  try:
268
- response = self.session.get(url, timeout=10)
269
+ response = requests.get(url, headers=self.headers, timeout=10)
269
270
  response.raise_for_status()
270
271
 
271
272
  url = response.json().get("file")
@@ -277,7 +278,7 @@ class Storage:
277
278
  exc.response, "Failed to get asset URL"
278
279
  ) from exc
279
280
  except Exception as exc:
280
- raise AutomizorError("Failed to get asset URL") from exc
281
+ raise AutomizorError(f"Failed to get asset URL: {exc}") from exc
281
282
 
282
283
  def _update_asset(self, name: str, content: bytes, content_type: str):
283
284
  """
@@ -300,11 +301,13 @@ class Storage:
300
301
  "name": name,
301
302
  }
302
303
  files = {"file": ("text.txt", content, content_type)}
303
- response = self.session.put(url, files=files, data=data, timeout=10)
304
+ response = requests.put(
305
+ url, headers=self.headers, files=files, data=data, timeout=10
306
+ )
304
307
  response.raise_for_status()
305
308
  except requests.HTTPError as exc:
306
309
  raise AutomizorError.from_response(
307
310
  exc.response, "Failed to update asset"
308
311
  ) from exc
309
312
  except Exception as exc:
310
- raise AutomizorError("Failed to update asset") from exc
313
+ raise AutomizorError(f"Failed to update asset: {exc}") from exc
automizor/vault/_vault.py CHANGED
@@ -44,15 +44,14 @@ class Vault:
44
44
 
45
45
  _instance = None
46
46
 
47
+ def __init__(self, api_token: str | None = None):
48
+ self.url, self.token = get_api_config(api_token)
49
+ self.headers = get_headers(self.token)
50
+
47
51
  @classmethod
48
52
  def configure(cls, api_token: str | None = None):
49
53
  cls._instance = cls(api_token)
50
54
 
51
- def __init__(self, api_token: str | None = None):
52
- self.url, self.token = get_api_config(api_token)
53
- self.session = requests.Session()
54
- self.session.headers.update(get_headers(self.token))
55
-
56
55
  @classmethod
57
56
  def get_instance(cls):
58
57
  if cls._instance is None:
@@ -114,7 +113,9 @@ class Vault:
114
113
  def _create_secret(self, secret: SecretContainer) -> SecretContainer:
115
114
  url = f"https://{self.url}/api/v1/vault/secret/"
116
115
  try:
117
- response = self.session.post(url, timeout=10, json=asdict(secret))
116
+ response = requests.post(
117
+ url, headers=self.headers, timeout=10, json=asdict(secret)
118
+ )
118
119
  response.raise_for_status()
119
120
  return SecretContainer(**response.json())
120
121
  except requests.HTTPError as exc:
@@ -122,12 +123,12 @@ class Vault:
122
123
  exc.response, "Failed to create secret"
123
124
  ) from exc
124
125
  except Exception as exc:
125
- raise AutomizorError("Failed to create secret") from exc
126
+ raise AutomizorError(f"Failed to create secret: {exc}") from exc
126
127
 
127
128
  def _get_secret(self, name: str) -> SecretContainer:
128
129
  url = f"https://{self.url}/api/v1/vault/secret/{name}/"
129
130
  try:
130
- response = self.session.get(url, timeout=10)
131
+ response = requests.get(url, headers=self.headers, timeout=10)
131
132
  response.raise_for_status()
132
133
  return SecretContainer(**response.json())
133
134
  except requests.HTTPError as exc:
@@ -135,12 +136,14 @@ class Vault:
135
136
  exc.response, "Failed to get secret"
136
137
  ) from exc
137
138
  except Exception as exc:
138
- raise AutomizorError("Failed to get secret") from exc
139
+ raise AutomizorError(f"Failed to get secret: {exc}") from exc
139
140
 
140
141
  def _update_secret(self, secret: SecretContainer) -> SecretContainer:
141
142
  url = f"https://{self.url}/api/v1/vault/secret/{secret.name}/"
142
143
  try:
143
- response = self.session.put(url, timeout=10, json=asdict(secret))
144
+ response = requests.put(
145
+ url, headers=self.headers, timeout=10, json=asdict(secret)
146
+ )
144
147
  response.raise_for_status()
145
148
  return SecretContainer(**response.json())
146
149
  except requests.HTTPError as exc:
@@ -148,4 +151,4 @@ class Vault:
148
151
  exc.response, "Failed to update secret"
149
152
  ) from exc
150
153
  except Exception as exc:
151
- raise AutomizorError("Failed to update secret") from exc
154
+ raise AutomizorError(f"Failed to update secret: {exc}") from exc
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: automizor
3
- Version: 0.4.8
3
+ Version: 0.4.10
4
4
  Summary: Python Automizor framework
5
5
  Home-page: https://github.com/automizor/automizor-python
6
6
  Author: Christian Fischer
@@ -1,20 +1,20 @@
1
- automizor/__init__.py,sha256=U86LejrmMsdC6N-YT7_w8TPLE0rJkGNw9YkhBt378b8,18
1
+ automizor/__init__.py,sha256=XxfULjVU_ewxlK1iP8zCIo68qAo_TYC2AAlK0zPbeS8,19
2
2
  automizor/exceptions.py,sha256=P5imySIOtG3ZIk2kh41Yod4RnlgTj7Vf0P3M-RuxQJs,1382
3
3
  automizor/datastore/__init__.py,sha256=_rAdRfKnTa4SuSLl9GkAYziBPPLsy6yGfS0HprgokOk,2418
4
4
  automizor/datastore/_container.py,sha256=rHRkSWaRgy2rk6Qy-7ADFKvuET_COZ2i9VD7gvRDnlM,745
5
- automizor/datastore/_datastore.py,sha256=WzWDxQ0ecSca7VEdjyKAtFxe2Ix0xnatjbKpgKmDzyc,3536
5
+ automizor/datastore/_datastore.py,sha256=Xtl64A-q3N9xP2lppPwgLNpqNMTHA5VoCO74T0vi-ZE,3349
6
6
  automizor/job/__init__.py,sha256=pDqSfR4lAyJNCi-fpG6byUPidHz8sntBs0bB2lJFVAY,1118
7
- automizor/job/_job.py,sha256=6U1Sd7aZLyoQW8wFkQMUr4HLEgljACe_sP2BTMSoyMU,5436
7
+ automizor/job/_job.py,sha256=TvZYxrl9JNXV5RZolOSdGMIQTNkiIy_MIPlDP2_-euM,5406
8
8
  automizor/log/__init__.py,sha256=gEr2SuwN1FgX1NMnbphjg8_gfSic9L15H3WC868A-TQ,2104
9
9
  automizor/log/_log.py,sha256=P9jAFXVANs5bAGH6-S0pzuSbRKEcX8VlQ_3uu690awE,2948
10
10
  automizor/storage/__init__.py,sha256=RF4ccSAd0UepvJx5NFiotKt9mVr5WiZCb_4qrJ5OKx0,4140
11
- automizor/storage/_storage.py,sha256=85LFN5Ed5ovvQgyFDmPL7RHaQUYjSTCn3-5nnkuTytA,11214
11
+ automizor/storage/_storage.py,sha256=fnYsvcExh6nMZg9YnSrDjbRWDD-szzRFTjcxXh4wIyY,11356
12
12
  automizor/utils/__init__.py,sha256=W0JNrn7GByjJXi60djS6vluo__Tj6AyJioqu9D41tto,952
13
13
  automizor/vault/__init__.py,sha256=21Ag2zQk7x27Bh0yt_kSO2MkgT3eafbdlKe0NuQEqr8,1796
14
14
  automizor/vault/_container.py,sha256=-2y7kASigoIVAebuQBk-0R_sI4gfmvjsMLuMg_tR1xA,1945
15
- automizor/vault/_vault.py,sha256=xyTaHbHEh4mMPmVuXHmPOSYvPm8h6QplrWeM1JUGLjk,4996
16
- automizor-0.4.8.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
17
- automizor-0.4.8.dist-info/METADATA,sha256=OIDwp9YdYFKFcUM5JJnvPaTJ_vDMC1hbeVwW3CMDfCI,668
18
- automizor-0.4.8.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
19
- automizor-0.4.8.dist-info/top_level.txt,sha256=gScDy4I3tP6BMYAsTAlBXrxVh3E00zV0UioxwXJOI3Y,10
20
- automizor-0.4.8.dist-info/RECORD,,
15
+ automizor/vault/_vault.py,sha256=WTKmm4QQhnBx2oWvYRuXi4hQEcf0srlJ64EN1hUJa6o,5078
16
+ automizor-0.4.10.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
17
+ automizor-0.4.10.dist-info/METADATA,sha256=plaIwWyN4HB2QZh87NHhHn6uRIvu_4t4Dc5NR6vOYX4,669
18
+ automizor-0.4.10.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
19
+ automizor-0.4.10.dist-info/top_level.txt,sha256=gScDy4I3tP6BMYAsTAlBXrxVh3E00zV0UioxwXJOI3Y,10
20
+ automizor-0.4.10.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (73.0.1)
2
+ Generator: setuptools (75.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5