nacwrap 1.2__tar.gz → 1.4__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.2 → nacwrap-1.4}/PKG-INFO +16 -1
- {nacwrap-1.2 → nacwrap-1.4}/README.md +15 -0
- {nacwrap-1.2 → nacwrap-1.4}/nacwrap/_auth.py +32 -15
- {nacwrap-1.2 → nacwrap-1.4}/nacwrap/_helpers.py +2 -2
- {nacwrap-1.2 → nacwrap-1.4}/nacwrap/tasks.py +4 -1
- {nacwrap-1.2 → nacwrap-1.4}/pyproject.toml +2 -2
- {nacwrap-1.2 → nacwrap-1.4}/pyproject.toml.orig +2 -2
- {nacwrap-1.2 → nacwrap-1.4}/nacwrap/__init__.py +0 -0
- {nacwrap-1.2 → nacwrap-1.4}/nacwrap/connections.py +0 -0
- {nacwrap-1.2 → nacwrap-1.4}/nacwrap/data_model.py +0 -0
- {nacwrap-1.2 → nacwrap-1.4}/nacwrap/datasources.py +0 -0
- {nacwrap-1.2 → nacwrap-1.4}/nacwrap/exceptions.py +0 -0
- {nacwrap-1.2 → nacwrap-1.4}/nacwrap/instances.py +0 -0
- {nacwrap-1.2 → nacwrap-1.4}/nacwrap/py.typed +0 -0
- {nacwrap-1.2 → nacwrap-1.4}/nacwrap/users.py +0 -0
- {nacwrap-1.2 → nacwrap-1.4}/nacwrap/workflows.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nacwrap
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4
|
|
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>
|
|
@@ -32,3 +32,18 @@ Several environment variables are required for nacwrap to function.
|
|
|
32
32
|
| Yes | NINTEX_CLIENT_SECRET | Client secret for connecting to Nintex API. Created in Apps and Tokens page in NAC. |
|
|
33
33
|
| Yes | NINTEX_GRANT_TYPE | Value should be 'client_credentials'. |
|
|
34
34
|
| Yes | NINTEX_BASE_URL | Value depends on which Nintex region you are in. US is, for example 'us.nintex.io'. <https://developer.nintex.com/docs/nc-api-docs/d2924cfeea6e8-welcome-to-the-nintex-automation-cloud-api#choose-your-region> |
|
|
35
|
+
|
|
36
|
+
## Running tests
|
|
37
|
+
|
|
38
|
+
Install the dev dependencies and run pytest:
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
uv sync
|
|
42
|
+
uv run pytest
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Unit tests mock the Nintex API and need no credentials. Live tests, which call the real API, are skipped by default. To run them, put real credentials in `.env` (see `.env.example`), plus a current `NTX_BEARER_TOKEN`, and set `RUN_LIVE_API_TESTS=1`:
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
RUN_LIVE_API_TESTS=1 uv run pytest -m live_api
|
|
49
|
+
```
|
|
@@ -16,3 +16,18 @@ Several environment variables are required for nacwrap to function.
|
|
|
16
16
|
| Yes | NINTEX_CLIENT_SECRET | Client secret for connecting to Nintex API. Created in Apps and Tokens page in NAC. |
|
|
17
17
|
| Yes | NINTEX_GRANT_TYPE | Value should be 'client_credentials'. |
|
|
18
18
|
| Yes | NINTEX_BASE_URL | Value depends on which Nintex region you are in. US is, for example 'us.nintex.io'. <https://developer.nintex.com/docs/nc-api-docs/d2924cfeea6e8-welcome-to-the-nintex-automation-cloud-api#choose-your-region> |
|
|
19
|
+
|
|
20
|
+
## Running tests
|
|
21
|
+
|
|
22
|
+
Install the dev dependencies and run pytest:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
uv sync
|
|
26
|
+
uv run pytest
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Unit tests mock the Nintex API and need no credentials. Live tests, which call the real API, are skipped by default. To run them, put real credentials in `.env` (see `.env.example`), plus a current `NTX_BEARER_TOKEN`, and set `RUN_LIVE_API_TESTS=1`:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
RUN_LIVE_API_TESTS=1 uv run pytest -m live_api
|
|
33
|
+
```
|
|
@@ -20,6 +20,12 @@ _P = ParamSpec("_P")
|
|
|
20
20
|
_R = TypeVar("_R")
|
|
21
21
|
|
|
22
22
|
|
|
23
|
+
class NintexAuthError(Exception):
|
|
24
|
+
"""
|
|
25
|
+
Raised when a Nintex bearer token cannot be obtained.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
|
|
23
29
|
class Decorators:
|
|
24
30
|
"""
|
|
25
31
|
The Decorators class is used to define functionality for getting
|
|
@@ -44,14 +50,17 @@ class Decorators:
|
|
|
44
50
|
A wrapper function used to check if the bearer token env vars
|
|
45
51
|
need to be refreshed.
|
|
46
52
|
"""
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
expires_at = os.environ.get(
|
|
54
|
+
"NTX_BEARER_TOKEN_EXPIRES_AT", "01/01/1901 00:00:00"
|
|
55
|
+
)
|
|
56
|
+
try:
|
|
57
|
+
expired = (
|
|
58
|
+
datetime.strptime(expires_at, "%m/%d/%Y %H:%M:%S") < datetime.now()
|
|
59
|
+
)
|
|
60
|
+
except ValueError:
|
|
61
|
+
logger.warning(f"Unparseable token expiry {expires_at!r}, refreshing")
|
|
62
|
+
expired = True
|
|
63
|
+
if "NTX_BEARER_TOKEN" not in os.environ or expired:
|
|
55
64
|
Decorators.get_token()
|
|
56
65
|
return decorated(*args, **kwargs)
|
|
57
66
|
|
|
@@ -63,13 +72,13 @@ class Decorators:
|
|
|
63
72
|
Get a new Nintex bearer token and set the corresponding environment variables.
|
|
64
73
|
"""
|
|
65
74
|
if "NINTEX_BASE_URL" not in os.environ:
|
|
66
|
-
raise
|
|
75
|
+
raise NintexAuthError("NINTEX_BASE_URL not set in environment")
|
|
67
76
|
if "NINTEX_CLIENT_ID" not in os.environ:
|
|
68
|
-
raise
|
|
77
|
+
raise NintexAuthError("NINTEX_CLIENT_ID not set in environment")
|
|
69
78
|
if "NINTEX_CLIENT_SECRET" not in os.environ:
|
|
70
|
-
raise
|
|
79
|
+
raise NintexAuthError("NINTEX_CLIENT_SECRET not set in environment")
|
|
71
80
|
if "NINTEX_GRANT_TYPE" not in os.environ:
|
|
72
|
-
raise
|
|
81
|
+
raise NintexAuthError("NINTEX_GRANT_TYPE not set in environment")
|
|
73
82
|
|
|
74
83
|
response = requests.post(
|
|
75
84
|
os.environ["NINTEX_BASE_URL"] + "/authentication/v1/token",
|
|
@@ -84,13 +93,21 @@ class Decorators:
|
|
|
84
93
|
},
|
|
85
94
|
timeout=30,
|
|
86
95
|
)
|
|
96
|
+
if not response.ok:
|
|
97
|
+
msg = (
|
|
98
|
+
f"Nintex token request failed ({response.status_code}): {response.text}"
|
|
99
|
+
)
|
|
100
|
+
logger.error(msg)
|
|
101
|
+
raise NintexAuthError(msg)
|
|
87
102
|
try:
|
|
88
103
|
os.environ["NTX_BEARER_TOKEN"] = response.json()["access_token"]
|
|
89
104
|
except Exception as e:
|
|
90
105
|
logger.error(f"Error, could not set OS env bearer token: {e}")
|
|
91
|
-
raise
|
|
106
|
+
raise NintexAuthError(
|
|
107
|
+
f"Error, could not set OS env bearer token: {e}"
|
|
108
|
+
) from e
|
|
92
109
|
try:
|
|
93
|
-
os.environ["
|
|
110
|
+
os.environ["NTX_BEARER_TOKEN_EXPIRES_AT"] = response.json()["expires_at"]
|
|
94
111
|
except Exception as e:
|
|
95
112
|
logger.error(f"Error, could not set os env expires at: {e}")
|
|
96
|
-
raise
|
|
113
|
+
raise NintexAuthError(f"Error, could not set os env expires at: {e}") from e
|
|
@@ -73,8 +73,8 @@ def _make_request(
|
|
|
73
73
|
)
|
|
74
74
|
response.raise_for_status()
|
|
75
75
|
except requests.exceptions.HTTPError as e:
|
|
76
|
-
logger.error(f"HTTP {
|
|
77
|
-
raise Exception(f"HTTP {
|
|
76
|
+
logger.error(f"HTTP {response.status_code} error, {context}: {e}")
|
|
77
|
+
raise Exception(f"HTTP {response.status_code} error, {context}: {e}") from e
|
|
78
78
|
except (requests.exceptions.ConnectionError, requests.exceptions.Timeout) as e:
|
|
79
79
|
logger.error(f"Connection error during {context}: {e}")
|
|
80
80
|
raise
|
|
@@ -167,7 +167,10 @@ def task_complete(task_id: str, assignment_id: str, outcome: str) -> None:
|
|
|
167
167
|
headers=_get_ntx_headers(),
|
|
168
168
|
context="complete task",
|
|
169
169
|
json={"outcome": outcome},
|
|
170
|
-
success_status_codes=[
|
|
170
|
+
success_status_codes=[
|
|
171
|
+
200,
|
|
172
|
+
204,
|
|
173
|
+
],
|
|
171
174
|
)
|
|
172
175
|
|
|
173
176
|
logger.info(f"Response Status: {response.status_code}")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "nacwrap"
|
|
3
|
-
version = "1.
|
|
3
|
+
version = "1.4"
|
|
4
4
|
description = "Python package that acts as a wrapper for the Nintex Automation Cloud system."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.10"
|
|
@@ -24,7 +24,7 @@ email = "jmaynor@pepsimidamerica.com"
|
|
|
24
24
|
Homepage = "https://github.com/pepsimidamerica/nacwrap"
|
|
25
25
|
|
|
26
26
|
[build-system]
|
|
27
|
-
requires = ["uv_build>=0.9.4,<0.
|
|
27
|
+
requires = ["uv_build>=0.9.4,<0.14.0"]
|
|
28
28
|
build-backend = "uv_build"
|
|
29
29
|
|
|
30
30
|
[tool.uv.build-backend]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "nacwrap"
|
|
3
|
-
version = "1.
|
|
3
|
+
version = "1.4"
|
|
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" }]
|
|
@@ -17,7 +17,7 @@ license-file = "LICENSE"
|
|
|
17
17
|
Homepage = "https://github.com/pepsimidamerica/nacwrap"
|
|
18
18
|
|
|
19
19
|
[build-system]
|
|
20
|
-
requires = ["uv_build>=0.9.4,<0.
|
|
20
|
+
requires = ["uv_build>=0.9.4,<0.14.0"]
|
|
21
21
|
build-backend = "uv_build"
|
|
22
22
|
|
|
23
23
|
[tool.uv.build-backend]
|
|
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
|