aplos-nca-saas-sdk 0.0.11__py3-none-any.whl → 0.0.13__py3-none-any.whl

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 (49) hide show
  1. aplos_nca_saas_sdk/integration_testing/configs/_config_base.py +7 -2
  2. aplos_nca_saas_sdk/integration_testing/configs/app_settings_config.py +88 -0
  3. aplos_nca_saas_sdk/integration_testing/configs/config_sample.json +31 -18
  4. aplos_nca_saas_sdk/integration_testing/configs/file_upload_config.py +94 -0
  5. aplos_nca_saas_sdk/integration_testing/configs/{login.py → login_config.py} +36 -23
  6. aplos_nca_saas_sdk/integration_testing/configs/nca_execution_config.py +186 -0
  7. aplos_nca_saas_sdk/integration_testing/files/executions/config1.json +46 -0
  8. aplos_nca_saas_sdk/integration_testing/integration_test_base.py +10 -3
  9. aplos_nca_saas_sdk/integration_testing/integration_test_configurations.py +15 -7
  10. aplos_nca_saas_sdk/integration_testing/integration_test_factory.py +1 -1
  11. aplos_nca_saas_sdk/integration_testing/integration_test_response.py +1 -1
  12. aplos_nca_saas_sdk/integration_testing/integration_test_suite.py +10 -3
  13. aplos_nca_saas_sdk/integration_testing/main.py +6 -6
  14. aplos_nca_saas_sdk/integration_testing/readme.md +1 -1
  15. aplos_nca_saas_sdk/integration_testing/tests/app_configuration_test.py +3 -3
  16. aplos_nca_saas_sdk/integration_testing/tests/app_login_test.py +4 -4
  17. aplos_nca_saas_sdk/integration_testing/tests/file_upload_test.py +44 -92
  18. aplos_nca_saas_sdk/integration_testing/tests/nca_analysis_test.py +89 -0
  19. aplos_nca_saas_sdk/integration_testing/tests/{app_execution_test.py → validation_test.py} +1 -1
  20. aplos_nca_saas_sdk/nca_resources/_api_base.py +44 -0
  21. aplos_nca_saas_sdk/{aws_resources → nca_resources}/aws_cognito.py +13 -7
  22. aplos_nca_saas_sdk/{aws_resources → nca_resources}/aws_s3_presigned_payload.py +3 -3
  23. aplos_nca_saas_sdk/{aws_resources → nca_resources}/aws_s3_presigned_upload.py +28 -22
  24. aplos_nca_saas_sdk/nca_resources/nca_analysis.py +304 -0
  25. aplos_nca_saas_sdk/nca_resources/nca_app_configuration.py +4 -4
  26. aplos_nca_saas_sdk/nca_resources/{nca_login.py → nca_authenticator.py} +26 -23
  27. aplos_nca_saas_sdk/nca_resources/nca_endpoints.py +56 -30
  28. aplos_nca_saas_sdk/nca_resources/nca_file_download.py +130 -0
  29. aplos_nca_saas_sdk/nca_resources/nca_file_upload.py +27 -29
  30. aplos_nca_saas_sdk/nca_resources/nca_validations.py +34 -0
  31. aplos_nca_saas_sdk/run_analysis_execution.py +148 -0
  32. aplos_nca_saas_sdk/utilities/commandline_args.py +32 -38
  33. aplos_nca_saas_sdk/utilities/environment_services.py +3 -2
  34. aplos_nca_saas_sdk/utilities/environment_vars.py +17 -4
  35. aplos_nca_saas_sdk/utilities/file_utility.py +33 -0
  36. aplos_nca_saas_sdk/utilities/http_utility.py +5 -14
  37. aplos_nca_saas_sdk/version.py +1 -1
  38. {aplos_nca_saas_sdk-0.0.11.dist-info → aplos_nca_saas_sdk-0.0.13.dist-info}/METADATA +1 -1
  39. aplos_nca_saas_sdk-0.0.13.dist-info/RECORD +51 -0
  40. {aplos_nca_saas_sdk-0.0.11.dist-info → aplos_nca_saas_sdk-0.0.13.dist-info}/licenses/LICENSE +1 -1
  41. aplos_nca_saas_sdk/integration_testing/configs/app_settings.py +0 -88
  42. aplos_nca_saas_sdk/integration_testing/configs/file_upload.py +0 -104
  43. aplos_nca_saas_sdk/integration_testing/tests/app_validation_test.py +0 -5
  44. aplos_nca_saas_sdk/nca_resources/nca_executions.py +0 -387
  45. aplos_nca_saas_sdk-0.0.11.dist-info/RECORD +0 -44
  46. /aplos_nca_saas_sdk/{files/analysis_files/single_ev/configuration_single_ev.json → sample_files/analysis_files/single_ev/config.json} +0 -0
  47. /aplos_nca_saas_sdk/{files/analysis_files/single_ev/single_ev.csv → sample_files/analysis_files/single_ev/input.csv} +0 -0
  48. /aplos_nca_saas_sdk/{files → sample_files}/analysis_files/single_ev/meta_data.json +0 -0
  49. {aplos_nca_saas_sdk-0.0.11.dist-info → aplos_nca_saas_sdk-0.0.13.dist-info}/WHEEL +0 -0
@@ -1,11 +1,11 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
6
6
 
7
- from typing import Dict, Any, List
8
7
  from abc import ABC, abstractmethod
8
+ from typing import List
9
9
 
10
10
  from aplos_nca_saas_sdk.integration_testing.integration_test_configurations import (
11
11
  TestConfiguration,
@@ -21,11 +21,18 @@ class IntegrationTestBase(ABC):
21
21
  """
22
22
 
23
23
  def __init__(self, name: str | None = None, index: int = 0):
24
- self.name = name
24
+ self.__name = name
25
25
  self.index = index
26
26
  self.__config: TestConfiguration = TestConfiguration()
27
27
  self.__results: List[IntegrationTestResponse] = []
28
28
 
29
+ @property
30
+ def name(self) -> str:
31
+ """
32
+ Get the name of the test
33
+ """
34
+ return self.__name if self.__name is not None else self.__class__.__name__
35
+
29
36
  @property
30
37
  def config(self) -> TestConfiguration:
31
38
  """
@@ -1,16 +1,21 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
6
6
 
7
7
  import json
8
8
  from typing import Any, Dict
9
- from aplos_nca_saas_sdk.integration_testing.configs.app_settings import (
9
+ from aplos_nca_saas_sdk.integration_testing.configs.app_settings_config import (
10
10
  ApplicationSettings,
11
11
  )
12
- from aplos_nca_saas_sdk.integration_testing.configs.file_upload import FileUploads
13
- from aplos_nca_saas_sdk.integration_testing.configs.login import Logins
12
+ from aplos_nca_saas_sdk.integration_testing.configs.file_upload_config import (
13
+ FileUploadConfigs,
14
+ )
15
+ from aplos_nca_saas_sdk.integration_testing.configs.login_config import LoginConfigs
16
+ from aplos_nca_saas_sdk.integration_testing.configs.nca_execution_config import (
17
+ NCAExecutionConfigs,
18
+ )
14
19
 
15
20
 
16
21
  class TestConfiguration:
@@ -21,8 +26,10 @@ class TestConfiguration:
21
26
 
22
27
  def __init__(self):
23
28
  self.app_config: ApplicationSettings = ApplicationSettings()
24
- self.logins: Logins = Logins()
25
- self.file_uploads: FileUploads = FileUploads()
29
+ self.logins: LoginConfigs = LoginConfigs()
30
+ self.file_uploads: FileUploadConfigs = FileUploadConfigs()
31
+ self.nca_executions: NCAExecutionConfigs = NCAExecutionConfigs()
32
+
26
33
  def load(self, file_path: str):
27
34
  """
28
35
  Loads the configuration from a file
@@ -37,4 +44,5 @@ class TestConfiguration:
37
44
 
38
45
  self.logins.load(config.get("login_test", {}))
39
46
  self.app_config.load(config.get("application_config_test", {}))
40
- self.file_uploads.load(config.get("file_upload_test", {}))
47
+ self.file_uploads.load(config.get("file_upload_test", {}))
48
+ self.nca_executions.load(config.get("analysis_execution_test", {}))
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
@@ -93,6 +93,8 @@ class IntegrationTestSuite:
93
93
  return len(failures) == 0
94
94
 
95
95
  def __print_results(self, start_time: datetime, failures: List[Dict[str, Any]]):
96
+ print("")
97
+ print("--------------------------------")
96
98
  print("Test Results:")
97
99
  skipped = sum([test["skipped_count"] for test in self.test_results])
98
100
 
@@ -101,8 +103,6 @@ class IntegrationTestSuite:
101
103
  print(
102
104
  f" {test_result['test_name']} {'succeeded' if test_result['success'] else 'failed'} duration: {duration}"
103
105
  )
104
- if not test_result["success"]:
105
- print(f" Errors: {test_result['errors']}")
106
106
 
107
107
  print(f"Test Suite completed in {datetime.now(UTC) - start_time}")
108
108
 
@@ -110,3 +110,10 @@ class IntegrationTestSuite:
110
110
  print(f" Successful: {len(self.test_results) - len(failures) - skipped}")
111
111
  print(f" Skipped: {skipped}")
112
112
  print(f" Failed: {len(failures)}")
113
+
114
+ if len(failures) > 0:
115
+ print("--------------------------------")
116
+
117
+ for test_result in self.test_results:
118
+ if not test_result["success"]:
119
+ print(f"Errors: {test_result['errors']}")
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
@@ -47,18 +47,18 @@ def override_config(config: TestConfiguration):
47
47
  """Override the configuration for the tests"""
48
48
  username = os.getenv("TEST_USERNAME")
49
49
  password = os.getenv("TEST_PASSWORD")
50
- domain = os.getenv("TEST_DOMAIN")
50
+ host = os.getenv("TEST_HOST")
51
51
 
52
- if not username or not password or not domain:
52
+ if not username or not password or not host:
53
53
  raise RuntimeError(
54
- "TEST_USERNAME, TEST_PASSWORD, and TEST_DOMAIN must be set in the environment"
54
+ "TEST_USERNAME, TEST_PASSWORD, and TEST_HOST must be set in the environment"
55
55
  )
56
56
 
57
57
  config.logins.list.clear()
58
- config.logins.add(username=username, password=password, domain=domain)
58
+ config.logins.add(username=username, password=password, host=host)
59
59
 
60
60
  config.app_config.domains.list.clear()
61
- config.app_config.domains.add(domain=domain)
61
+ config.app_config.domains.add(host=host)
62
62
 
63
63
 
64
64
  if __name__ == "__main__":
@@ -9,7 +9,7 @@ The integration tests will require the following:
9
9
  ### Environment Vars
10
10
  |Variable Name|Description|
11
11
  |--|--|
12
- |APLOS_API_DOMAIN|The full domain. e.g. app.aplos-nca.com|
12
+ |APLOS_host|The full host name. e.g. app.aplos-nca.com|
13
13
 
14
14
 
15
15
  ### Users
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
@@ -27,10 +27,10 @@ class TestAppConfiguration(IntegrationTestBase):
27
27
 
28
28
  self.results.clear()
29
29
  for domain_config in self.config.app_config.domains.list:
30
- config: NCAAppConfiguration = NCAAppConfiguration(domain_config.domain)
30
+ config: NCAAppConfiguration = NCAAppConfiguration(domain_config.host)
31
31
 
32
32
  test_response: IntegrationTestResponse = IntegrationTestResponse()
33
- test_response.meta = {"domain": domain_config}
33
+ test_response.meta = {"host": domain_config}
34
34
 
35
35
  if not domain_config.enabled or not self.config.app_config.enabled:
36
36
  test_response.skipped = True
@@ -1,10 +1,10 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
6
6
 
7
- from aplos_nca_saas_sdk.nca_resources.nca_login import NCALogin
7
+ from aplos_nca_saas_sdk.nca_resources.nca_authenticator import NCAAuthenticator
8
8
 
9
9
 
10
10
  from aplos_nca_saas_sdk.integration_testing.integration_test_base import (
@@ -35,11 +35,11 @@ class TestAppLogin(IntegrationTestBase):
35
35
  self.results.append(test_response)
36
36
  continue
37
37
  try:
38
- nca_login = NCALogin(aplos_saas_domain=login.domain)
38
+ nca_login = NCAAuthenticator(host=login.host)
39
39
  token = nca_login.authenticate(
40
40
  username=login.username, password=login.password
41
41
  )
42
- test_response.response = token
42
+
43
43
  if not token:
44
44
  test_response.error = "Failed to authenticate"
45
45
 
@@ -1,16 +1,16 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
6
6
 
7
7
  import time
8
8
  from datetime import datetime, timedelta
9
- from typing import Any, Dict
9
+ from typing import Any, Dict, List
10
10
 
11
11
  import requests
12
12
  from aws_lambda_powertools import Logger
13
- from aplos_nca_saas_sdk.integration_testing.configs.login import Login
13
+ from aplos_nca_saas_sdk.integration_testing.configs.login_config import LoginConfig
14
14
  from aplos_nca_saas_sdk.integration_testing.integration_test_base import (
15
15
  IntegrationTestBase,
16
16
  )
@@ -18,8 +18,12 @@ from aplos_nca_saas_sdk.integration_testing.integration_test_response import (
18
18
  IntegrationTestResponse,
19
19
  )
20
20
  from aplos_nca_saas_sdk.nca_resources.nca_file_upload import NCAFileUpload
21
- from aplos_nca_saas_sdk.nca_resources.nca_login import NCALogin
21
+ from aplos_nca_saas_sdk.nca_resources.nca_file_download import NCAFileDownload
22
+ from aplos_nca_saas_sdk.nca_resources.nca_authenticator import NCAAuthenticator
22
23
  from aplos_nca_saas_sdk.utilities.http_utility import HttpUtilities
24
+ from aplos_nca_saas_sdk.integration_testing.configs.file_upload_config import (
25
+ FileUploadConfig,
26
+ )
23
27
 
24
28
  logger = Logger()
25
29
 
@@ -35,28 +39,30 @@ class FileUploadTest(IntegrationTestBase):
35
39
 
36
40
  self.results.clear()
37
41
 
38
- for fileupload in self.config.file_uploads.list:
42
+ file_upload: FileUploadConfig
43
+ for file_upload in self.config.file_uploads.list:
39
44
  test_response: IntegrationTestResponse = IntegrationTestResponse()
40
45
  test_response.name = self.name
41
46
  try:
42
47
  # Confirm Login
43
- nca_login = self.__login(fileupload.login)
44
- if not nca_login.jwt:
45
- test_response.error = "Failed to authenticate"
48
+ nca_login = self.__login(file_upload.login)
49
+ # if not nca_login.cognito.jwt:
50
+ # test_response.error = "Failed to authenticate"
51
+ # else:
52
+ # Confirm Upload
53
+ upload_response: Dict[str, Any] = self.__upload(
54
+ nca_login, file_upload.file_path
55
+ )
56
+ if upload_response is None:
57
+ test_response.error = "Failed to upload"
46
58
  else:
47
- # Confirm Upload
48
- upload_response: Dict[str, Any] = self.__upload(
49
- nca_login, fileupload.filepath
50
- )
51
- if upload_response is None:
52
- test_response.error = "Failed to upload"
53
- else:
54
- # Confirm conversion and download
55
- # Allow time buffer so file data is available
56
- time.sleep(3)
57
- self.__download(
58
- nca_login, upload_response.get("file_id"), test_response
59
- )
59
+ # Confirm conversion and download
60
+ # Allow time buffer so file data is available
61
+ file_id: str = upload_response.get("file_id", "")
62
+ if not file_id:
63
+ raise RuntimeError("Failed to get a file_id from the upload")
64
+ time.sleep(3)
65
+ self.__download(nca_login, file_id, test_response)
60
66
 
61
67
  except Exception as e: # pylint: disable=w0718
62
68
  test_response.error = str(e)
@@ -65,91 +71,37 @@ class FileUploadTest(IntegrationTestBase):
65
71
 
66
72
  return self.success()
67
73
 
68
- def __login(self, login: Login) -> NCALogin:
69
- nca_login = NCALogin(aplos_saas_domain=login.domain)
74
+ def __login(self, login: LoginConfig) -> NCAAuthenticator:
75
+ nca_login = NCAAuthenticator(host=login.host)
70
76
  nca_login.authenticate(username=login.username, password=login.password)
71
77
  return nca_login
72
78
 
73
- def __upload(self, nca_login: NCALogin, upload_file_path: str) -> Dict[str, Any]:
79
+ def __upload(self, auth: NCAAuthenticator, upload_file_path: str) -> Dict[str, Any]:
74
80
  logger.info({"message": "Uploading file", "file_path": upload_file_path})
75
81
 
76
- nca_file_upload = NCAFileUpload(nca_login)
82
+ nca_file_upload = NCAFileUpload(auth.host)
83
+ nca_file_upload.authenticator = auth
77
84
  upload_response: Dict[str, Any] = nca_file_upload.upload(upload_file_path)
78
85
  return upload_response
79
86
 
80
87
  def __download(
81
88
  self,
82
- nca_login: NCALogin,
89
+ nca_login: NCAAuthenticator,
83
90
  file_id: str,
84
91
  test_response: IntegrationTestResponse,
85
92
  ):
86
93
  logger.info({"message": "Downloading file", "file_id": file_id})
87
- file_data_endpoint = nca_login.config.endpoints.file_data(
88
- nca_login.cognito.tenant_id,
89
- nca_login.cognito.user_id,
90
- file_id,
91
- )
92
- file_info_endpoint = nca_login.config.endpoints.file(
93
- nca_login.cognito.tenant_id,
94
- nca_login.cognito.user_id,
95
- file_id,
96
- )
97
-
98
- max_wait_in_minutes: int = 3
99
- headers = HttpUtilities.get_headers(nca_login.jwt)
100
- current_time = datetime.now()
101
-
102
- # Create a timedelta object representing 3 minutes
103
- time_delta = timedelta(minutes=max_wait_in_minutes)
104
- # Add the timedelta to the current time
105
- max_time = current_time + time_delta
106
-
107
- complete = False
108
- while not complete:
109
- response = requests.get(file_info_endpoint, headers=headers, timeout=60)
110
- json_response: dict = response.json()
111
- errors = []
112
- errors.extend(json_response.get("errors") or [])
113
- status = json_response.get("workable_state")
114
- complete = status == "ready"
115
-
116
- if status == "invalid" or len(errors) > 0:
117
- test_response.success = False
118
- test_response.error = (
119
- "File conversion failed."
120
- if len(errors) < 0
121
- else f"File conversion failed with errors ${errors}."
122
- )
123
- break
124
- if complete:
125
- break
126
- if not complete:
127
- time.sleep(5)
128
- if datetime.now() > max_time:
129
- test_response.success = False
130
- test_response.error = (
131
- "Timeout attempting to get conversion file status. "
132
- f"The current timeout limit is {max_wait_in_minutes} minutes. "
133
- "You may need to up the timeout period, or check for errors. "
134
- )
135
- break
136
-
137
- if test_response.error is not None:
138
- return
94
+ downloader: NCAFileDownload = NCAFileDownload(nca_login.host)
95
+ downloader.authenticator = nca_login
96
+ response = downloader.download(file_id)
139
97
 
140
- file_response = requests.get(file_data_endpoint, headers=headers, timeout=30)
141
-
142
- json_file_response: dict = file_response.json()
143
- data = json_file_response.get("data", None)
144
- error = json_file_response.get("error", None)
145
-
146
- if data is None:
98
+ status = response.get("workable_state")
99
+ if status != "ready":
147
100
  test_response.success = False
148
- test_response.error = "File download missing expected data. "
149
- if error is not None:
150
- test_response.success = False
151
- test_response.error = (
152
- test_response.error or ""
153
- ) + f"File download contained error ${error}"
101
+ test_response.error = f"File conversion failed. Status: {status}"
102
+ else:
103
+ test_response.success = True
104
+
105
+ test_response.response = response
154
106
 
155
- test_response.success = True
107
+ return response
@@ -0,0 +1,89 @@
1
+ """
2
+ Copyright 2024-2025 Aplos Analytics
3
+ All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
+ Property of Aplos Analytics, Utah, USA
5
+ """
6
+
7
+ from pathlib import Path
8
+
9
+ from aws_lambda_powertools import Logger
10
+
11
+ from aplos_nca_saas_sdk.integration_testing.integration_test_base import (
12
+ IntegrationTestBase,
13
+ )
14
+ from aplos_nca_saas_sdk.integration_testing.integration_test_response import (
15
+ IntegrationTestResponse,
16
+ )
17
+ from aplos_nca_saas_sdk.nca_resources.nca_analysis import NCAAnalysis
18
+ from aplos_nca_saas_sdk.utilities.file_utility import FileUtility
19
+
20
+ logger = Logger(service="NCAAnalysisTest")
21
+
22
+
23
+ class NCAAnalysisTest(IntegrationTestBase):
24
+ """NCA Execution Test Container"""
25
+
26
+ def __init__(self):
27
+ super().__init__("nca-execution")
28
+
29
+ def test(self) -> bool:
30
+ """Test Engine Execution"""
31
+
32
+ self.results.clear()
33
+
34
+ for nca_execution_config in self.config.nca_executions.list:
35
+ test_response: IntegrationTestResponse = IntegrationTestResponse()
36
+ test_response.name = self.name
37
+
38
+ input_file_path = (
39
+ FileUtility.load_filepath(nca_execution_config.input_file_path),
40
+ )
41
+ logger.info(
42
+ {
43
+ "message": "Creating NCA Analysis Execution for input file.",
44
+ "path": input_file_path,
45
+ "path2": nca_execution_config.input_file_path,
46
+ }
47
+ )
48
+ try:
49
+ # Create new NCA Execution
50
+ nca_execution: NCAAnalysis = NCAAnalysis(
51
+ nca_execution_config.login.host
52
+ )
53
+
54
+ # Initialize Configuration Data
55
+
56
+ # Execute, the execution should raise errors that will fail the test
57
+ logger.info({"message": "Invoking Execution"})
58
+ execution_response = nca_execution.execute(
59
+ username=nca_execution_config.login.username,
60
+ password=nca_execution_config.login.password,
61
+ input_file_path=FileUtility.load_filepath(
62
+ nca_execution_config.input_file_path
63
+ ),
64
+ config_data=nca_execution_config.config_data,
65
+ meta_data=nca_execution_config.meta_data,
66
+ wait_for_results=True,
67
+ output_directory=nca_execution_config.output_dir,
68
+ unzip_after_download=False,
69
+ )
70
+
71
+ # Verify Download
72
+ logger.info(
73
+ {"message": "Execution complete. Verifying results download."}
74
+ )
75
+
76
+ expected_output_file = execution_response.get("results", {}).get("file")
77
+ if expected_output_file is None:
78
+ raise RuntimeError(
79
+ "Expected populated output_file from NCAExecution was None."
80
+ )
81
+ elif not Path(expected_output_file).is_file():
82
+ raise RuntimeError("Expected downloaded file does not exist.")
83
+
84
+ except Exception as e: # pylint: disable=w0718
85
+ test_response.error = str(e)
86
+
87
+ self.results.append(test_response)
88
+
89
+ return self.success()
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
@@ -0,0 +1,44 @@
1
+ """
2
+ Copyright 2024-2025 Aplos Analytics
3
+ All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
+ Property of Aplos Analytics, Utah, USA
5
+ """
6
+
7
+ from typing import Any
8
+
9
+
10
+ from aplos_nca_saas_sdk.nca_resources.nca_authenticator import NCAAuthenticator
11
+ from aplos_nca_saas_sdk.nca_resources.nca_endpoints import NCAEndpoints
12
+
13
+
14
+ class NCAApiBaseClass:
15
+ """NCA Api Base Class"""
16
+
17
+ def __init__(self, host: str) -> None:
18
+ self.host = host
19
+ self.__authenticator: NCAAuthenticator = NCAAuthenticator(host=host)
20
+ self.__endpoints: NCAEndpoints = NCAEndpoints(host=host)
21
+ if not host:
22
+ raise ValueError("Missing Aplos Api Domain")
23
+
24
+ @property
25
+ def authenticator(self) -> NCAAuthenticator:
26
+ """Gets the authenticator"""
27
+
28
+ return self.__authenticator
29
+
30
+ @authenticator.setter
31
+ def authenticator(self, value: Any) -> None:
32
+ """Sets the authenticator"""
33
+
34
+ self.__authenticator = value
35
+
36
+ @property
37
+ def endpoints(self) -> NCAEndpoints:
38
+ """Gets the endpoints"""
39
+
40
+ if self.authenticator.cognito.jwt:
41
+ self.__endpoints.tenant_id = self.authenticator.cognito.tenant_id
42
+ self.__endpoints.user_id = self.authenticator.cognito.user_id
43
+
44
+ return self.__endpoints
@@ -1,5 +1,5 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
@@ -14,10 +14,9 @@ from aplos_nca_saas_sdk.nca_resources.nca_app_configuration import (
14
14
  )
15
15
 
16
16
 
17
- class CognitoAuthenication:
17
+ class CognitoAuthentication:
18
18
  """
19
19
  Cognito Authentication
20
-
21
20
  """
22
21
 
23
22
  def __init__(
@@ -73,22 +72,26 @@ class CognitoAuthenication:
73
72
  return self.__region
74
73
 
75
74
  def __validate_parameters(self) -> None:
75
+ """
76
+ Validate the required parameters.
77
+ We need either:
78
+ - the Cognito ClientId and Cognito Region
79
+ - or the Aplos Domain (which can get the clientId and region)
80
+ """
76
81
  if self.__client_id is None and self.__aplos_domain is not None:
77
- self.__config = NCAAppConfiguration(aplos_saas_domain=self.__aplos_domain)
82
+ self.__config = NCAAppConfiguration(host=self.__aplos_domain)
78
83
  self.__client_id = self.__config.cognito_client_id
79
84
  self.__region = self.__config.cognito_region
80
85
 
81
86
  if self.__client_id is None:
82
87
  raise RuntimeError(
83
88
  "Missing Cognito Client Id. "
84
- "Pass in a client_id as a command arg or set the COGNITO_CLIENT_ID enviornment var. "
85
89
  "Alternatively, set the aplos_domain to automatically get the client_id and region."
86
90
  )
87
91
 
88
92
  if self.__region is None:
89
93
  raise RuntimeError(
90
94
  "Missing Cognito Region"
91
- "Pass in a region as a command arg or set the COGNITO_REGION enviornment var. "
92
95
  "Alternatively, set the aplos_domain to automatically get the client_id and region."
93
96
  )
94
97
 
@@ -139,13 +142,16 @@ class CognitoAuthenication:
139
142
  self.__parse_jwt(self.__jwt)
140
143
  return self.__jwt
141
144
 
142
- raise RuntimeError("Failed to get a JWT token")
145
+ raise RuntimeError(
146
+ "Failed to get a JWT token. Check the error logs for more information."
147
+ )
143
148
 
144
149
  def __parse_jwt(self, encoded_jwt: str) -> None:
145
150
  # Decode the payload (second part) from Base64
146
151
  decoded_jwt: dict = jwt_lib.decode(
147
152
  encoded_jwt, options={"verify_signature": False}
148
153
  )
154
+ # custom fields contain information we'll need for later requests
149
155
  self.__user_id = decoded_jwt.get("custom:aplos_user_id")
150
156
  self.__tenant_id = decoded_jwt.get("custom:aplos_user_tenant_id")
151
157
 
@@ -1,12 +1,12 @@
1
1
  """
2
- Copyright 2024 Aplos Analytics
2
+ Copyright 2024-2025 Aplos Analytics
3
3
  All Rights Reserved. www.aplosanalytics.com LICENSED MATERIALS
4
4
  Property of Aplos Analytics, Utah, USA
5
5
  """
6
6
 
7
7
 
8
- class S3PresignedPayload:
9
- """S3PresignedPayload"""
8
+ class S3PresignedUrlPayload:
9
+ """S3 Presigned Url Payload"""
10
10
 
11
11
  def __init__(self, payload: dict | None = None) -> None:
12
12
  self.url: str | None = None