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.
- {nacwrap-1.0 → nacwrap-1.2}/PKG-INFO +1 -1
- {nacwrap-1.0 → nacwrap-1.2}/nacwrap/_auth.py +20 -10
- {nacwrap-1.0 → nacwrap-1.2}/nacwrap/data_model.py +3 -1
- {nacwrap-1.0 → nacwrap-1.2}/nacwrap/instances.py +1 -2
- nacwrap-1.2/nacwrap/py.typed +0 -0
- nacwrap-1.2/pyproject.toml +42 -0
- nacwrap-1.0/pyproject.toml → nacwrap-1.2/pyproject.toml.orig +1 -1
- {nacwrap-1.0 → nacwrap-1.2}/README.md +0 -0
- {nacwrap-1.0 → nacwrap-1.2}/nacwrap/__init__.py +0 -0
- {nacwrap-1.0 → nacwrap-1.2}/nacwrap/_helpers.py +0 -0
- {nacwrap-1.0 → nacwrap-1.2}/nacwrap/connections.py +0 -0
- {nacwrap-1.0 → nacwrap-1.2}/nacwrap/datasources.py +0 -0
- {nacwrap-1.0 → nacwrap-1.2}/nacwrap/exceptions.py +0 -0
- {nacwrap-1.0 → nacwrap-1.2}/nacwrap/tasks.py +0 -0
- {nacwrap-1.0 → nacwrap-1.2}/nacwrap/users.py +0 -0
- {nacwrap-1.0 → nacwrap-1.2}/nacwrap/workflows.py +0 -0
|
@@ -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
|
-
|
|
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=
|
|
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
|
-
"""
|
|
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
|
-
|
|
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
|
+
]
|
|
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
|