ITK-dev-shared-components 2.11.0__tar.gz → 2.12.0__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 (48) hide show
  1. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/PKG-INFO +2 -1
  2. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/eflyt/eflyt_search.py +16 -16
  3. itk_dev_shared_components-2.12.0/itk_dev_shared_components/getorganized/go_api.py +154 -0
  4. itk_dev_shared_components-2.12.0/itk_dev_shared_components/smtp/__init__.py +0 -0
  5. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components.egg-info/PKG-INFO +2 -1
  6. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components.egg-info/SOURCES.txt +2 -0
  7. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components.egg-info/requires.txt +1 -0
  8. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/pyproject.toml +3 -2
  9. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/LICENSE +0 -0
  10. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/README.md +0 -0
  11. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/__init__.py +0 -0
  12. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/eflyt/__init__.py +0 -0
  13. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/eflyt/eflyt_case.py +0 -0
  14. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/eflyt/eflyt_login.py +0 -0
  15. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/eflyt/eflyt_util.py +0 -0
  16. {itk_dev_shared_components-2.11.0/itk_dev_shared_components/graph → itk_dev_shared_components-2.12.0/itk_dev_shared_components/getorganized}/__init__.py +0 -0
  17. {itk_dev_shared_components-2.11.0/itk_dev_shared_components/misc → itk_dev_shared_components-2.12.0/itk_dev_shared_components/graph}/__init__.py +0 -0
  18. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/graph/authentication.py +0 -0
  19. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/graph/common.py +0 -0
  20. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/graph/file.py +0 -0
  21. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/graph/mail.py +0 -0
  22. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/graph/site.py +0 -0
  23. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/kmd_nova/__init__.py +0 -0
  24. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/kmd_nova/authentication.py +0 -0
  25. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/kmd_nova/cpr.py +0 -0
  26. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/kmd_nova/nova_cases.py +0 -0
  27. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/kmd_nova/nova_documents.py +0 -0
  28. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/kmd_nova/nova_notes.py +0 -0
  29. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/kmd_nova/nova_objects.py +0 -0
  30. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/kmd_nova/nova_tasks.py +0 -0
  31. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/kmd_nova/util.py +0 -0
  32. {itk_dev_shared_components-2.11.0/itk_dev_shared_components/sap → itk_dev_shared_components-2.12.0/itk_dev_shared_components/misc}/__init__.py +0 -0
  33. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/misc/address_lookup.py +0 -0
  34. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/misc/cpr_util.py +0 -0
  35. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/misc/cvr_lookup.py +0 -0
  36. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/misc/file_util.py +0 -0
  37. {itk_dev_shared_components-2.11.0/itk_dev_shared_components/smtp → itk_dev_shared_components-2.12.0/itk_dev_shared_components/sap}/__init__.py +0 -0
  38. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/sap/fmcacov.py +0 -0
  39. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/sap/gridview_util.py +0 -0
  40. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/sap/multi_session.py +0 -0
  41. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/sap/opret_kundekontakt.py +0 -0
  42. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/sap/sap_login.py +0 -0
  43. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/sap/sap_util.py +0 -0
  44. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/sap/tree_util.py +0 -0
  45. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components/smtp/smtp_util.py +0 -0
  46. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components.egg-info/dependency_links.txt +0 -0
  47. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/itk_dev_shared_components.egg-info/top_level.txt +0 -0
  48. {itk_dev_shared_components-2.11.0 → itk_dev_shared_components-2.12.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: itk_dev_shared_components
3
- Version: 2.11.0
3
+ Version: 2.12.0
4
4
  Summary: Shared components to use in RPA projects
5
5
  Author-email: ITK Development <itk-rpa@mkb.aarhus.dk>
6
6
  Project-URL: Homepage, https://github.com/itk-dev-rpa/itk-dev-shared-components
@@ -17,6 +17,7 @@ Requires-Dist: requests==2.*
17
17
  Requires-Dist: beautifulsoup4==4.*
18
18
  Requires-Dist: selenium==4.*
19
19
  Requires-Dist: uiautomation==2.*
20
+ Requires-Dist: requests_ntlm==1.*
20
21
  Provides-Extra: dev
21
22
  Requires-Dist: python-dotenv; extra == "dev"
22
23
  Requires-Dist: flake8; extra == "dev"
@@ -58,33 +58,33 @@ def extract_cases(browser: webdriver.Chrome) -> list[Case]:
58
58
  """
59
59
  table = browser.find_element(By.ID, "ctl00_ContentPlaceHolder2_GridViewSearchResult")
60
60
  rows = table.find_elements(By.TAG_NAME, "tr")
61
+ headlines = rows[0].text.split(" ")
62
+
61
63
  # Remove header row
62
64
  rows.pop(0)
63
65
  cases = []
64
66
  for row in rows:
65
- deadline = row.find_element(By.XPATH, "td[3]/a").text
66
-
67
- # Convert deadline to date object
68
- if deadline:
69
- deadline = datetime.strptime(deadline, "%d-%m-%Y")
70
- else:
71
- deadline = None
67
+ deadline = None
68
+ if "Deadline" in headlines:
69
+ deadline_text = row.find_element(By.XPATH, f"td[{headlines.index('Deadline') + 1}]/a").text
70
+ # Convert deadline to date object
71
+ if len(deadline_text) > 0:
72
+ deadline = datetime.strptime(deadline_text, "%d-%m-%Y")
72
73
 
73
- case_number = row.find_element(By.XPATH, "td[4]").text
74
- case_types_text = row.find_element(By.XPATH, "td[5]").text
74
+ case_number = row.find_element(By.XPATH, f"td[{headlines.index('Sagsnr.') + 1}]").text
75
+ case_types_text = row.find_element(By.XPATH, f"td[{headlines.index('Flyttetype') + 1}]").text
75
76
 
76
77
  # If the case types ends with '...' we need to get the title instead
77
78
  if case_types_text.endswith("..."):
78
- case_types_text = row.find_element(By.XPATH, "td[5]").get_attribute("Title")
79
+ case_types_text = row.find_element(By.XPATH, f"td[{headlines.index('Flyttetype') + 1}]").get_attribute("Title")
79
80
  case_types = case_types_text.split(", ")
80
81
 
81
- status = row.find_element(By.XPATH, "td[6]").text
82
- cpr = row.find_element(By.XPATH, "td[7]/a").text
83
- name = row.find_element(By.XPATH, "td[8]").text
84
- case_worker = row.find_element(By.XPATH, "td[10]").text
82
+ status = row.find_element(By.XPATH, f"td[{headlines.index('Status') + 1}]").text
83
+ cpr = row.find_element(By.XPATH, f"td[{headlines.index('CPR-nr.') + 1}]/a").text
84
+ name = row.find_element(By.XPATH, f"td[{headlines.index('Navn') + 1}]").text
85
+ case_worker = row.find_element(By.XPATH, f"td[{headlines.index('Sagsbehandler') + 2}]").text # eFlyt has an additional empty column before "Sagsbehandler"
85
86
 
86
- case = Case(case_number, deadline, case_types, status, cpr, name, case_worker)
87
- cases.append(case)
87
+ cases.append(Case(case_number, deadline, case_types, status, cpr, name, case_worker))
88
88
 
89
89
  return cases
90
90
 
@@ -0,0 +1,154 @@
1
+ """Functions for working with the GetOrganized API."""
2
+
3
+ import json
4
+ from urllib.parse import urljoin
5
+ from typing import Literal
6
+
7
+ from requests import Session
8
+ from requests_ntlm import HttpNtlmAuth
9
+
10
+
11
+ def create_session(username: str, password: str) -> Session:
12
+ """Create a session for accessing GetOrganized API.
13
+
14
+ Args:
15
+ username: Username for login.
16
+ password: Password for login.
17
+
18
+ Returns:
19
+ Return the session object
20
+ """
21
+ session = Session()
22
+ session.headers.setdefault("Content-Type", "application/json")
23
+ session.auth = HttpNtlmAuth(username, password)
24
+ return session
25
+
26
+
27
+ def upload_document(*, apiurl: str, file: bytearray, case_id: str, filename: str, agent_name: str | None = None, date_string: str | None = None, session: Session, doc_category: str | None = None, case_type: str = Literal["EMN", "GEO"], overwrite: bool = True) -> tuple[str, Session]:
28
+ """Upload a document to Get Organized.
29
+
30
+ Args:
31
+ apiurl: Base url for API.
32
+ session: Session token for request.
33
+ file: Bytearray of file to upload.
34
+ case_id: Case ID already present in GO.
35
+ filename: Name of file when saved in GO.
36
+ agent_name: Agent name, used for creating a folder in GO. Defaults to None.
37
+ date_string: A date to add as metadata to GetOrganized. Defaults to None.
38
+
39
+ Returns:
40
+ Return response text.
41
+ """
42
+ url = apiurl + "/_goapi/Documents/AddToCase"
43
+ payload = {
44
+ "Bytes": list(file),
45
+ "CaseId": case_id,
46
+ "SiteUrl": urljoin(apiurl, f"/case{case_type}/{case_id}"),
47
+ "ListName": "Dokumenter",
48
+ "FolderPath": agent_name,
49
+ "FileName": filename,
50
+ "Metadata": f"<z:row xmlns:z='#RowsetSchema' ows_Dato='{date_string}' ows_Kategori='{doc_category}'/>",
51
+ "Overwrite": overwrite
52
+ }
53
+ response = session.post(url, data=json.dumps(payload), timeout=60)
54
+ response.raise_for_status()
55
+ return response.text
56
+
57
+
58
+ def delete_document(apiurl: str, document_id: int, session: Session) -> tuple[str, Session]:
59
+ """Delete a document from GetOrganized.
60
+
61
+ Args:
62
+ apiurl: Url of the GetOrganized API.
63
+ session: Session object used for logging in.
64
+ document_id: ID of the document to delete.
65
+
66
+ Returns:
67
+ Return the response.
68
+ """
69
+ url = urljoin(apiurl, "/_goapi/Documents/ByDocumentId/")
70
+ payload = {
71
+ "DocId": document_id,
72
+ "ForceDelete": True
73
+ }
74
+ response = session.delete(url, timeout=60, data=json.dumps(payload))
75
+ response.raise_for_status()
76
+ return response
77
+
78
+
79
+ def create_case(session: Session, apiurl: str, title: str, category: str, department: str, kle: str, case_type: str = Literal["EMN", "GEO"]) -> str:
80
+ """Create a case in GetOrganized.
81
+
82
+ Args:
83
+ apiurl: Url for the GetOrganized API.
84
+ session: Session object to access API.
85
+ title: Title of the case being created.
86
+ category: Case category to create the case for.
87
+ department: Department for the case.
88
+ kle: KLE number for the case (https://www.kle-online.dk/emneplan/00/)
89
+
90
+ Returns:
91
+ Return the caseID of the created case.
92
+ """
93
+ url = urljoin(apiurl, "/_goapi/Cases/")
94
+ payload = {
95
+ 'CaseTypePrefix': case_type,
96
+ 'MetadataXml': f'''<z:row xmlns:z="#RowsetSchema"
97
+ ows_Title="{title}"
98
+ ows_CaseStatus="Åben"
99
+ ows_CaseCategory="{category}"
100
+ ows_Afdeling="{department}"
101
+ ows_KLENummer="{kle}"/>''',
102
+ 'ReturnWhenCaseFullyCreated': False
103
+ }
104
+ response = session.post(url, data=json.dumps(payload), timeout=60)
105
+ response.raise_for_status()
106
+ return response.json()["CaseID"]
107
+
108
+
109
+ def get_case_metadata(session: Session, apiurl: str, case_id: str) -> str:
110
+ """Get metadata for a GetOrganized case, to look through parameters and values.
111
+
112
+ Args:
113
+ session: Session token.
114
+ apiurl: Base URL for the API.
115
+ case_id: Case ID to get metadata on.
116
+
117
+ Returns:
118
+ Return the metadata for the case as an XML string.
119
+ """
120
+ url = urljoin(apiurl, f"/_goapi/Cases/Metadata/{case_id}")
121
+ response = session.get(url, timeout=60)
122
+ response.raise_for_status()
123
+ return response.json()["Metadata"]
124
+
125
+
126
+ def find_case(session: Session, apiurl: str, case_title: str, case_type: str = Literal["EMN", "GEO"]) -> list[str]:
127
+ """Search for an existing case in GO with the given case title.
128
+ The search finds any case that contains the given title in its title.
129
+
130
+ Args:
131
+ case_title: The title to search for.
132
+ session: Session object to access the API.
133
+
134
+ Returns:
135
+ The case id of the found case(s) if any.
136
+ """
137
+ url = apiurl + "/_goapi/Cases/FindByCaseProperties"
138
+ payload = {
139
+ "FieldProperties": [
140
+ {
141
+ "InternalName": "ows_Title",
142
+ "Value": case_title,
143
+ "ComparisonType": "Contains",
144
+ }
145
+ ],
146
+ "CaseTypePrefixes": [case_type],
147
+ "LogicalOperator": "AND",
148
+ "ExcludeDeletedCases": True
149
+ }
150
+ response = session.post(url, data=json.dumps(payload), timeout=60)
151
+ response.raise_for_status()
152
+ cases = response.json()['CasesInfo']
153
+
154
+ return [case['CaseID'] for case in cases]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: itk_dev_shared_components
3
- Version: 2.11.0
3
+ Version: 2.12.0
4
4
  Summary: Shared components to use in RPA projects
5
5
  Author-email: ITK Development <itk-rpa@mkb.aarhus.dk>
6
6
  Project-URL: Homepage, https://github.com/itk-dev-rpa/itk-dev-shared-components
@@ -17,6 +17,7 @@ Requires-Dist: requests==2.*
17
17
  Requires-Dist: beautifulsoup4==4.*
18
18
  Requires-Dist: selenium==4.*
19
19
  Requires-Dist: uiautomation==2.*
20
+ Requires-Dist: requests_ntlm==1.*
20
21
  Provides-Extra: dev
21
22
  Requires-Dist: python-dotenv; extra == "dev"
22
23
  Requires-Dist: flake8; extra == "dev"
@@ -12,6 +12,8 @@ itk_dev_shared_components/eflyt/eflyt_case.py
12
12
  itk_dev_shared_components/eflyt/eflyt_login.py
13
13
  itk_dev_shared_components/eflyt/eflyt_search.py
14
14
  itk_dev_shared_components/eflyt/eflyt_util.py
15
+ itk_dev_shared_components/getorganized/__init__.py
16
+ itk_dev_shared_components/getorganized/go_api.py
15
17
  itk_dev_shared_components/graph/__init__.py
16
18
  itk_dev_shared_components/graph/authentication.py
17
19
  itk_dev_shared_components/graph/common.py
@@ -4,6 +4,7 @@ requests==2.*
4
4
  beautifulsoup4==4.*
5
5
  selenium==4.*
6
6
  uiautomation==2.*
7
+ requests_ntlm==1.*
7
8
 
8
9
  [dev]
9
10
  python-dotenv
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "itk_dev_shared_components"
7
- version = "2.11.0"
7
+ version = "2.12.0"
8
8
  authors = [
9
9
  { name="ITK Development", email="itk-rpa@mkb.aarhus.dk" },
10
10
  ]
@@ -22,7 +22,8 @@ dependencies = [
22
22
  "requests == 2.*",
23
23
  "beautifulsoup4 == 4.*",
24
24
  "selenium == 4.*",
25
- "uiautomation == 2.*"
25
+ "uiautomation == 2.*",
26
+ "requests_ntlm == 1.*"
26
27
  ]
27
28
 
28
29
  [project.urls]