nacwrap 0.2.0__tar.gz → 0.2.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.
Files changed (26) hide show
  1. {nacwrap-0.2.0/nacwrap.egg-info → nacwrap-0.2.2}/PKG-INFO +1 -1
  2. {nacwrap-0.2.0 → nacwrap-0.2.2}/nacwrap/data_model.py +19 -1
  3. nacwrap-0.2.2/nacwrap/exceptions.py +2 -0
  4. {nacwrap-0.2.0 → nacwrap-0.2.2}/nacwrap/instances.py +1 -1
  5. {nacwrap-0.2.0 → nacwrap-0.2.2}/nacwrap/nacwrap.py +2 -0
  6. nacwrap-0.2.2/nacwrap/workflows.py +94 -0
  7. {nacwrap-0.2.0 → nacwrap-0.2.2/nacwrap.egg-info}/PKG-INFO +1 -1
  8. {nacwrap-0.2.0 → nacwrap-0.2.2}/nacwrap.egg-info/SOURCES.txt +1 -0
  9. {nacwrap-0.2.0 → nacwrap-0.2.2}/setup.py +1 -1
  10. nacwrap-0.2.0/nacwrap/workflows.py +0 -25
  11. {nacwrap-0.2.0 → nacwrap-0.2.2}/LICENSE +0 -0
  12. {nacwrap-0.2.0 → nacwrap-0.2.2}/MANIFEST.in +0 -0
  13. {nacwrap-0.2.0 → nacwrap-0.2.2}/README.md +0 -0
  14. {nacwrap-0.2.0 → nacwrap-0.2.2}/nacwrap/__init__.py +0 -0
  15. {nacwrap-0.2.0 → nacwrap-0.2.2}/nacwrap/_auth.py +0 -0
  16. {nacwrap-0.2.0 → nacwrap-0.2.2}/nacwrap/_helpers.py +0 -0
  17. {nacwrap-0.2.0 → nacwrap-0.2.2}/nacwrap/connections.py +0 -0
  18. {nacwrap-0.2.0 → nacwrap-0.2.2}/nacwrap/datasources.py +0 -0
  19. {nacwrap-0.2.0 → nacwrap-0.2.2}/nacwrap/tasks.py +0 -0
  20. {nacwrap-0.2.0 → nacwrap-0.2.2}/nacwrap/users.py +0 -0
  21. {nacwrap-0.2.0 → nacwrap-0.2.2}/nacwrap.egg-info/dependency_links.txt +0 -0
  22. {nacwrap-0.2.0 → nacwrap-0.2.2}/nacwrap.egg-info/requires.txt +0 -0
  23. {nacwrap-0.2.0 → nacwrap-0.2.2}/nacwrap.egg-info/top_level.txt +0 -0
  24. {nacwrap-0.2.0 → nacwrap-0.2.2}/requirements.txt +0 -0
  25. {nacwrap-0.2.0 → nacwrap-0.2.2}/setup.cfg +0 -0
  26. {nacwrap-0.2.0 → nacwrap-0.2.2}/tests/test.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nacwrap
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Python package that acts as a wrapper for the Nintex Automation Cloud system.
5
5
  Home-page: https://github.com/pepsimidamerica/nacwrap
6
6
  Author: Jordan Maynor
@@ -39,6 +39,7 @@ class TaskStatus(str, Enum):
39
39
  return member
40
40
  return None
41
41
 
42
+
42
43
  class ResolveType(Enum):
43
44
  RETRY = "1"
44
45
  FAIL = "2"
@@ -61,12 +62,16 @@ class InstanceActions(BaseModel):
61
62
  type: str
62
63
  parentId: Optional[str] = Field(default=None)
63
64
  startDateTime: Optional[datetime] = Field(default=None)
65
+ endDateTime: Optional[datetime] = Field(default=None)
64
66
  errorMessage: Optional[str] = Field(default=None)
65
67
  logMessage: Optional[str] = Field(default=None)
66
68
 
67
69
  @property
68
70
  def age(self) -> timedelta:
69
- return datetime.now(timezone.utc) - self.startDateTime
71
+ if self.startDateTime:
72
+ return datetime.now(timezone.utc) - self.startDateTime
73
+ else:
74
+ return timedelta(days=0)
70
75
 
71
76
  # NintexInstance attributes
72
77
  instanceId: str
@@ -77,6 +82,7 @@ class InstanceActions(BaseModel):
77
82
  workflow: Workflow
78
83
  actions: List[Action]
79
84
 
85
+
80
86
  class NintexInstance(BaseModel):
81
87
  class Workflow(BaseModel):
82
88
  id: str
@@ -162,5 +168,17 @@ class NintexUser(BaseModel):
162
168
  return self.firstName + " " + self.lastName
163
169
 
164
170
 
171
+ class NintexWorkflows(BaseModel):
172
+ """Response Data Model for Nintex Workflows API Endpoints."""
173
+
174
+ class Workflow(BaseModel):
175
+ id: str
176
+ name: str
177
+ lastModified: datetime
178
+
179
+ # NintexWorkflows Attributes
180
+ workflows: List[Workflow]
181
+
182
+
165
183
  class InstanceStartData(BaseModel):
166
184
  pass
@@ -0,0 +1,2 @@
1
+ class WorkflowApiError(Exception):
2
+ pass
@@ -184,7 +184,7 @@ def instances_list(
184
184
  "from": (
185
185
  from_datetime.strftime("%Y-%m-%dT%H:%M:%S.%fZ") if from_datetime else None
186
186
  ),
187
- "to": to_datetime.strftime("%Y-%m-%dT%H:%M:%S.%fZ") if to_datetime else None,
187
+ "to": to_datetime.strftime("%Y-%m-%dT23:59:59.0000000Z") if to_datetime else None,
188
188
  "pageSize": page_size,
189
189
  }
190
190
 
@@ -6,3 +6,5 @@ from .instances import *
6
6
  from .tasks import *
7
7
  from .users import *
8
8
  from .data_model import *
9
+ from .workflows import *
10
+ from .exceptions import *
@@ -0,0 +1,94 @@
1
+ """
2
+ This module contains functions to interact with workflows
3
+ """
4
+
5
+ import json
6
+ import os
7
+ from datetime import datetime
8
+ from typing import Literal, Optional, Union
9
+
10
+ import requests
11
+
12
+ from nacwrap._auth import Decorators
13
+ from nacwrap._helpers import _fetch_page, _post
14
+ from nacwrap.data_model import *
15
+ from nacwrap.exceptions import *
16
+
17
+
18
+ # TODO List workflows
19
+ @Decorators.refresh_token
20
+ def workflows_list(limit: int = 1000) -> dict:
21
+ """Get Nintex Workflow information.
22
+
23
+ Args:
24
+ limit (int, optional): Max number of workflows to return. Defaults to 1000.
25
+
26
+ Raises:
27
+ WorkflowApiError: Generic error when API call fails.
28
+
29
+ Returns:
30
+ list[dict]: _description_
31
+ """
32
+
33
+ base_url = (
34
+ os.environ["NINTEX_BASE_URL"] + f"/workflows/v1/designs/published?limit={limit}"
35
+ )
36
+ results = []
37
+ url = base_url
38
+
39
+ while url:
40
+
41
+ try:
42
+ response = _fetch_page(
43
+ url,
44
+ headers={
45
+ "Authorization": "Bearer " + os.environ["NTX_BEARER_TOKEN"],
46
+ "Content-Type": "application/json",
47
+ },
48
+ )
49
+ response.raise_for_status()
50
+ except requests.exceptions.HTTPError as e:
51
+ raise WorkflowApiError(
52
+ f"Error, could not get workflow data: {e.response.status_code} - {e.response.content}"
53
+ )
54
+ except requests.exceptions.RequestException as e:
55
+ raise WorkflowApiError(f"Error, could not get workflow data: {e}")
56
+
57
+ data = response.json()
58
+ results += data["workflows"]
59
+ url = data.get("nextLink")
60
+
61
+ return results
62
+
63
+
64
+ def workflows_list_pd(limit: int = 1000) -> NintexWorkflows:
65
+ """Get Nintex Workflow information.
66
+ Returns data as a pydantic data model.
67
+
68
+ Returns:
69
+ NintexWorkflows: Pydantic data model of API response.
70
+ """
71
+
72
+ workflows = workflows_list(limit=limit)
73
+ return NintexWorkflows(workflows=workflows)
74
+
75
+
76
+ # TODO List Workflow permissions
77
+
78
+ # TODO Update workflow permissions
79
+
80
+ # TODO Get a workflow design
81
+
82
+ # TODO Delete a workflow
83
+
84
+ # TODO Deactivate a workflow
85
+
86
+ # TODO Activate a workflow
87
+
88
+ # TODO Add tags to a workflow
89
+
90
+ # TODO Export a draft workflow
91
+
92
+ # TODO Export a published workflow
93
+
94
+ # TODO Import a workflow
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nacwrap
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Python package that acts as a wrapper for the Nintex Automation Cloud system.
5
5
  Home-page: https://github.com/pepsimidamerica/nacwrap
6
6
  Author: Jordan Maynor
@@ -9,6 +9,7 @@ nacwrap/_helpers.py
9
9
  nacwrap/connections.py
10
10
  nacwrap/data_model.py
11
11
  nacwrap/datasources.py
12
+ nacwrap/exceptions.py
12
13
  nacwrap/instances.py
13
14
  nacwrap/nacwrap.py
14
15
  nacwrap/tasks.py
@@ -8,7 +8,7 @@ with open("README.md", "r") as f:
8
8
 
9
9
  setup(
10
10
  name="nacwrap",
11
- version="0.2.0",
11
+ version="0.2.02",
12
12
  description="Python package that acts as a wrapper for the Nintex Automation Cloud system.",
13
13
  long_description=long_description,
14
14
  long_description_content_type="text/markdown",
@@ -1,25 +0,0 @@
1
- """
2
- This module contains functions to interact with workflows
3
- """
4
-
5
- # TODO List workflows
6
-
7
- # TODO List Workflow permissions
8
-
9
- # TODO Update workflow permissions
10
-
11
- # TODO Get a workflow design
12
-
13
- # TODO Delete a workflow
14
-
15
- # TODO Deactivate a workflow
16
-
17
- # TODO Activate a workflow
18
-
19
- # TODO Add tags to a workflow
20
-
21
- # TODO Export a draft workflow
22
-
23
- # TODO Export a published workflow
24
-
25
- # TODO Import a workflow
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
File without changes
File without changes
File without changes
File without changes