nacwrap 1.0__tar.gz → 1.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.4
2
2
  Name: nacwrap
3
- Version: 1.0
3
+ Version: 1.2
4
4
  Summary: Python package that acts as a wrapper for the Nintex Automation Cloud system.
5
5
  Author: Jordan Maynor
6
6
  Author-email: Jordan Maynor <jmaynor@pepsimidamerica.com>
@@ -8,12 +8,18 @@ import logging
8
8
  import os
9
9
  from collections.abc import Callable
10
10
  from datetime import datetime
11
+ from functools import wraps
12
+ from typing import ParamSpec, TypeVar
11
13
 
12
14
  import requests
13
15
 
14
16
  logger = logging.getLogger(__name__)
15
17
 
16
18
 
19
+ _P = ParamSpec("_P")
20
+ _R = TypeVar("_R")
21
+
22
+
17
23
  class Decorators:
18
24
  """
19
25
  The Decorators class is used to define functionality for getting
@@ -21,13 +27,19 @@ class Decorators:
21
27
  """
22
28
 
23
29
  @staticmethod
24
- def refresh_token(decorated: Callable) -> Callable:
30
+ def refresh_token(decorated: Callable[_P, _R]) -> Callable[_P, _R]:
25
31
  """
26
32
  Decorator to refresh the access token if it has expired or generate
27
33
  a new one if it does not exist.
34
+
35
+ :param decorated: The callable to decorate.
36
+ :type decorated: Callable
37
+ :return: The wrapped callable with token refresh logic.
38
+ :rtype: Callable
28
39
  """
29
40
 
30
- def wrapper(*args, **kwargs) -> Callable:
41
+ @wraps(decorated)
42
+ def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _R:
31
43
  """
32
44
  A wrapper function used to check if the bearer token env vars
33
45
  need to be refreshed.
@@ -43,7 +55,6 @@ class Decorators:
43
55
  Decorators.get_token()
44
56
  return decorated(*args, **kwargs)
45
57
 
46
- wrapper.__name__ = decorated.__name__
47
58
  return wrapper
48
59
 
49
60
  @staticmethod
@@ -60,13 +71,12 @@ class Decorators:
60
71
  if "NINTEX_GRANT_TYPE" not in os.environ:
61
72
  raise Exception("NINTEX_GRANT_TYPE not set in environment")
62
73
 
63
- headers = {
64
- "Accept": "application/json",
65
- "Content-Type": "application/x-www-form-urlencoded",
66
- }
67
74
  response = requests.post(
68
75
  os.environ["NINTEX_BASE_URL"] + "/authentication/v1/token",
69
- headers=headers,
76
+ headers={
77
+ "Accept": "application/json",
78
+ "Content-Type": "application/x-www-form-urlencoded",
79
+ },
70
80
  data={
71
81
  "client_id": os.environ["NINTEX_CLIENT_ID"],
72
82
  "client_secret": os.environ["NINTEX_CLIENT_SECRET"],
@@ -78,9 +88,9 @@ class Decorators:
78
88
  os.environ["NTX_BEARER_TOKEN"] = response.json()["access_token"]
79
89
  except Exception as e:
80
90
  logger.error(f"Error, could not set OS env bearer token: {e}")
81
- raise Exception(f"Error, could not set OS env bearer token: {e}")
91
+ raise Exception(f"Error, could not set OS env bearer token: {e}") from e
82
92
  try:
83
93
  os.environ["NTX_EXPIRES_AT"] = response.json()["expires_at"]
84
94
  except Exception as e:
85
95
  logger.error(f"Error, could not set os env expires at: {e}")
86
- raise Exception(f"Error, could not set os env expires at: {e}")
96
+ raise Exception(f"Error, could not set os env expires at: {e}") from e
@@ -112,7 +112,8 @@ class InstanceActions(BaseModel):
112
112
  actions: list[Action]
113
113
 
114
114
  def action_is_running(self, action_instance_id: str) -> bool:
115
- """Looks for actions matching action_instance_id that are completed. Some actions are listed as completed
115
+ """
116
+ Looks for actions matching action_instance_id that are completed. Some actions are listed as completed
116
117
  by another entry in the Actions list of the instance, while the first instance of the action is still in a status of running.
117
118
 
118
119
  Args:
@@ -121,6 +122,7 @@ class InstanceActions(BaseModel):
121
122
 
122
123
  Returns:
123
124
  bool: True if action was completed.
125
+
124
126
  """
125
127
  for action in self.actions:
126
128
  if (
@@ -3,7 +3,6 @@ Module contains functions for getting info about and interacting with
3
3
  workflow instances.
4
4
  """
5
5
 
6
- import json
7
6
  import logging
8
7
  import os
9
8
  from datetime import datetime
@@ -52,7 +51,7 @@ def create_instance(workflow_id: str, start_data: dict | None = None) -> dict:
52
51
  url=url,
53
52
  headers=_get_ntx_headers(),
54
53
  context="creating instance",
55
- data=json.dumps({"startData": start_data or {}}),
54
+ json={"startData": start_data or {}},
56
55
  )
57
56
 
58
57
  return response.json()
File without changes
@@ -0,0 +1,42 @@
1
+ [project]
2
+ name = "nacwrap"
3
+ version = "1.2"
4
+ description = "Python package that acts as a wrapper for the Nintex Automation Cloud system."
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ dependencies = [
8
+ "pydantic>=2.12.5",
9
+ "requests>=2.32.5",
10
+ "tenacity>=9.1.2",
11
+ ]
12
+ classifiers = [
13
+ "Programming Language :: Python :: 3",
14
+ "Operating System :: OS Independent",
15
+ ]
16
+ license = "Unlicense"
17
+ license-file = "LICENSE"
18
+
19
+ [[project.authors]]
20
+ name = "Jordan Maynor"
21
+ email = "jmaynor@pepsimidamerica.com"
22
+
23
+ [project.urls]
24
+ Homepage = "https://github.com/pepsimidamerica/nacwrap"
25
+
26
+ [build-system]
27
+ requires = ["uv_build>=0.9.4,<0.12.0"]
28
+ build-backend = "uv_build"
29
+
30
+ [tool.uv.build-backend]
31
+ module-name = "nacwrap"
32
+ module-root = ""
33
+
34
+ [tool.pytest.ini_options]
35
+ testpaths = ["tests"]
36
+ markers = ["live_api: opt-in tests that make real network calls to the Nintex API"]
37
+
38
+ [dependency-groups]
39
+ dev = [
40
+ "pytest>=9.0.2",
41
+ "python-dotenv>=1.1.0",
42
+ ]
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "nacwrap"
3
- version = "1.0"
3
+ version = "1.2"
4
4
  description = "Python package that acts as a wrapper for the Nintex Automation Cloud system."
5
5
  readme = "README.md"
6
6
  authors = [{ name = "Jordan Maynor", email = "jmaynor@pepsimidamerica.com" }]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes