intuned-runtime 1.3.0rc0__py3-none-any.whl → 1.3.2__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 (45) hide show
  1. intuned_cli/__init__.py +15 -24
  2. intuned_cli/commands/__init__.py +6 -1
  3. intuned_cli/commands/attempt_api_command.py +8 -0
  4. intuned_cli/commands/attempt_authsession_check_command.py +8 -0
  5. intuned_cli/commands/attempt_authsession_command.py +4 -4
  6. intuned_cli/commands/attempt_authsession_create_command.py +9 -1
  7. intuned_cli/commands/attempt_command.py +4 -4
  8. intuned_cli/commands/authsession_command.py +12 -0
  9. intuned_cli/commands/authsession_record_command.py +54 -0
  10. intuned_cli/commands/command.py +6 -4
  11. intuned_cli/commands/deploy_command.py +2 -0
  12. intuned_cli/commands/init_command.py +2 -0
  13. intuned_cli/commands/run_api_command.py +9 -1
  14. intuned_cli/commands/run_authsession_command.py +4 -4
  15. intuned_cli/commands/run_authsession_create_command.py +34 -4
  16. intuned_cli/commands/run_authsession_update_command.py +33 -4
  17. intuned_cli/commands/run_authsession_validate_command.py +32 -3
  18. intuned_cli/commands/run_command.py +4 -4
  19. intuned_cli/commands/save_command.py +2 -0
  20. intuned_cli/controller/__test__/test_api.py +159 -18
  21. intuned_cli/controller/__test__/test_authsession.py +497 -6
  22. intuned_cli/controller/api.py +40 -39
  23. intuned_cli/controller/authsession.py +213 -110
  24. intuned_cli/controller/deploy.py +3 -3
  25. intuned_cli/controller/save.py +47 -48
  26. intuned_cli/types.py +14 -0
  27. intuned_cli/utils/__test__/test_browser.py +132 -0
  28. intuned_cli/utils/__test__/test_traces.py +27 -0
  29. intuned_cli/utils/api_helpers.py +54 -5
  30. intuned_cli/utils/auth_session_helpers.py +42 -7
  31. intuned_cli/utils/backend.py +4 -1
  32. intuned_cli/utils/browser.py +63 -0
  33. intuned_cli/utils/error.py +14 -0
  34. intuned_cli/utils/exclusions.py +1 -0
  35. intuned_cli/utils/help.py +9 -0
  36. intuned_cli/utils/traces.py +31 -0
  37. intuned_cli/utils/wrapper.py +58 -0
  38. intuned_internal_cli/__init__.py +7 -0
  39. {intuned_runtime-1.3.0rc0.dist-info → intuned_runtime-1.3.2.dist-info}/METADATA +4 -2
  40. {intuned_runtime-1.3.0rc0.dist-info → intuned_runtime-1.3.2.dist-info}/RECORD +45 -37
  41. runtime/browser/launch_chromium.py +19 -8
  42. runtime/types/settings_types.py +13 -4
  43. {intuned_runtime-1.3.0rc0.dist-info → intuned_runtime-1.3.2.dist-info}/WHEEL +0 -0
  44. {intuned_runtime-1.3.0rc0.dist-info → intuned_runtime-1.3.2.dist-info}/entry_points.txt +0 -0
  45. {intuned_runtime-1.3.0rc0.dist-info → intuned_runtime-1.3.2.dist-info}/licenses/LICENSE +0 -0
intuned_cli/__init__.py CHANGED
@@ -1,3 +1,4 @@
1
+ import logging
1
2
  import os
2
3
  import sys
3
4
 
@@ -5,13 +6,15 @@ import arguably
5
6
  from dotenv import find_dotenv
6
7
  from dotenv import load_dotenv
7
8
 
8
- from intuned_cli.utils.console import console
9
- from intuned_cli.utils.error import CLIError
10
- from intuned_cli.utils.error import log_automation_error
9
+ import intuned_cli.commands # pyright: ignore[reportUnusedImport] # noqa: F401
10
+ from intuned_cli.utils.error import CLIExit
11
11
  from runtime.context.context import IntunedContext
12
- from runtime.errors.run_api_errors import RunApiError
13
12
 
14
- from . import commands
13
+ logging.basicConfig(level=logging.WARNING, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
14
+
15
+ logging.getLogger("runtime").setLevel(logging.INFO)
16
+ logging.getLogger("intuned_runtime").setLevel(logging.INFO)
17
+ logging.getLogger("intuned_browser").setLevel(logging.INFO)
15
18
 
16
19
 
17
20
  def run():
@@ -29,22 +32,10 @@ def run():
29
32
  os.environ["FUNCTIONS_DOMAIN"] = get_base_url().replace("/$", "")
30
33
  try:
31
34
  with IntunedContext():
32
- arguably.run(name="intuned")
33
- sys.exit(0)
34
- except CLIError as e:
35
- if e.auto_color:
36
- console.print(f"[bold red]{e.message}[/bold red]")
37
- else:
38
- console.print(e.message)
39
- except RunApiError as e:
40
- log_automation_error(e)
41
- except KeyboardInterrupt:
42
- console.print("[bold red]Aborted[/bold red]")
43
- except Exception as e:
44
- console.print(
45
- f"[red][bold]An error occurred: [/bold]{e}\n[bold]Please report this issue to the Intuned team.[/bold]"
46
- )
47
- sys.exit(1)
48
-
49
-
50
- __all__ = ["commands", "run"]
35
+ arguably.run(name="intuned", output=sys.stderr)
36
+ return 0
37
+ except CLIExit as e:
38
+ return e.code
39
+
40
+
41
+ __all__ = ["run"]
@@ -7,13 +7,18 @@ from .attempt_authsession_create_command import (
7
7
  attempt__authsession__create as attempt__authsession__create, # type: ignore
8
8
  )
9
9
  from .attempt_command import attempt as attempt # type: ignore
10
+ from .authsession_command import authsession as authsession # type: ignore
11
+ from .authsession_record_command import authsession__record as authsession__record # type: ignore
10
12
  from .command import __root__ as __root__ # type: ignore
11
13
  from .deploy_command import deploy as deploy # type: ignore
12
14
  from .init_command import init as init # type: ignore
13
15
  from .run_api_command import run__api as run__api # type: ignore
14
16
  from .run_authsession_command import run__authsession as run__authsession # type: ignore
17
+ from .run_authsession_create_command import authsession__create as authsession__create # type: ignore
15
18
  from .run_authsession_create_command import run__authsession__create as run__authsession__create # type: ignore
16
- from .run_authsession_update_command import run__authsession__update as run__authsession__update # type: ignore
19
+ from .run_authsession_update_command import authsession__update as authsession__update # type: ignore
20
+ from .run_authsession_update_command import run_authsession__update as run_authsession__update # type: ignore
21
+ from .run_authsession_validate_command import authsession__validate as authsession__validate # type: ignore
17
22
  from .run_authsession_validate_command import run__authsession__validate as run__authsession__validate # type: ignore
18
23
  from .run_command import run as run # type: ignore
19
24
  from .save_command import save as save # type: ignore
@@ -4,9 +4,11 @@ import pytimeparse # type: ignore
4
4
  from intuned_cli.controller.api import execute_attempt_api_cli
5
5
  from intuned_cli.utils.auth_session_helpers import assert_auth_consistent
6
6
  from intuned_cli.utils.auth_session_helpers import load_parameters
7
+ from intuned_cli.utils.wrapper import cli_command
7
8
 
8
9
 
9
10
  @arguably.command # type: ignore
11
+ @cli_command
10
12
  async def attempt__api(
11
13
  api_name: str,
12
14
  parameters: str,
@@ -17,6 +19,8 @@ async def attempt__api(
17
19
  timeout: str = "10 min",
18
20
  headless: bool = False,
19
21
  output_file: str | None = None,
22
+ trace: bool = False,
23
+ keep_browser_open: bool = False,
20
24
  ):
21
25
  """Executes an Intuned API attempt with parameters
22
26
 
@@ -28,6 +32,8 @@ async def attempt__api(
28
32
  timeout (str, optional): [--timeout]. Timeout - seconds or pytimeparse-formatted string. Defaults to "10 min".
29
33
  headless (bool, optional): [--headless]. Run the API in headless mode (default: False). This will not open a browser window.
30
34
  output_file (str | None, optional): [-o/--output-file]. Output file path. Defaults to None.
35
+ trace (bool, optional): [--trace]. Capture a trace of each attempt, useful for debugging. Defaults to False.
36
+ keep_browser_open (bool, optional): [--keep-browser-open]. Keep the last browser open after execution for debugging. Defaults to False.
31
37
  """
32
38
 
33
39
  await assert_auth_consistent(auth_session)
@@ -48,4 +54,6 @@ async def attempt__api(
48
54
  timeout=timeout_value,
49
55
  headless=headless,
50
56
  output_file=output_file,
57
+ trace=trace,
58
+ keep_browser_open=keep_browser_open,
51
59
  )
@@ -3,9 +3,11 @@ import pytimeparse # type: ignore
3
3
 
4
4
  from intuned_cli.controller.authsession import execute_attempt_check_auth_session_cli
5
5
  from intuned_cli.utils.auth_session_helpers import assert_auth_enabled
6
+ from intuned_cli.utils.wrapper import cli_command
6
7
 
7
8
 
8
9
  @arguably.command # type: ignore
10
+ @cli_command
9
11
  async def attempt__authsession__check(
10
12
  id: str,
11
13
  /,
@@ -13,6 +15,8 @@ async def attempt__authsession__check(
13
15
  proxy: str | None = None,
14
16
  timeout: str = "10 min",
15
17
  headless: bool = False,
18
+ trace: bool = False,
19
+ keep_browser_open: bool = False,
16
20
  ):
17
21
  """Check an existing auth session
18
22
 
@@ -21,6 +25,8 @@ async def attempt__authsession__check(
21
25
  proxy (str | None, optional): [--proxy]. Proxy URL to use for the auth session command. Defaults to None.
22
26
  timeout (str, optional): [--timeout]. Timeout for the auth session command - seconds or pytimeparse-formatted string. Defaults to "10 min".
23
27
  headless (bool, optional): [--headless]. Run the API in headless mode (default: False). This will not open a browser window.
28
+ trace (bool, optional): [--trace]. Capture a trace of each attempt, useful for debugging. Defaults to False.
29
+ keep_browser_open (bool, optional): [--keep-browser-open]. Keep the last browser open after execution for debugging. Defaults to False.
24
30
  """
25
31
  await assert_auth_enabled()
26
32
 
@@ -35,4 +41,6 @@ async def attempt__authsession__check(
35
41
  headless=headless,
36
42
  timeout=timeout_value,
37
43
  proxy=proxy,
44
+ trace=trace,
45
+ keep_browser_open=keep_browser_open,
38
46
  )
@@ -1,12 +1,12 @@
1
1
  import arguably
2
2
 
3
- from intuned_cli.utils.console import console
3
+ from intuned_cli.utils.help import print_help_and_exit
4
+ from intuned_cli.utils.wrapper import cli_command
4
5
 
5
6
 
6
7
  @arguably.command # type: ignore
8
+ @cli_command
7
9
  async def attempt__authsession():
8
10
  """Execute san Intuned authsession attempt"""
9
11
 
10
- if arguably.is_target():
11
- console.print(" (-h/--help) for usage")
12
- exit(1)
12
+ print_help_and_exit()
@@ -4,9 +4,11 @@ import pytimeparse # type: ignore
4
4
  from intuned_cli.controller.authsession import execute_attempt_create_auth_session_cli
5
5
  from intuned_cli.utils.auth_session_helpers import assert_auth_enabled
6
6
  from intuned_cli.utils.auth_session_helpers import load_parameters
7
+ from intuned_cli.utils.wrapper import cli_command
7
8
 
8
9
 
9
10
  @arguably.command # type: ignore
11
+ @cli_command
10
12
  async def attempt__authsession__create(
11
13
  parameters: str,
12
14
  /,
@@ -15,6 +17,8 @@ async def attempt__authsession__create(
15
17
  proxy: str | None = None,
16
18
  timeout: str = "10 min",
17
19
  headless: bool = False,
20
+ trace: bool = False,
21
+ keep_browser_open: bool = False,
18
22
  ):
19
23
  """Create a new auth session
20
24
 
@@ -24,8 +28,10 @@ async def attempt__authsession__create(
24
28
  proxy (str | None, optional): [--proxy]. Proxy URL to use for the auth session command. Defaults to None.
25
29
  timeout (str, optional): [--timeout]. Timeout for the auth session command - seconds or pytimeparse-formatted string. Defaults to "10 min".
26
30
  headless (bool, optional): [--headless]. Run the API in headless mode (default: False). This will not open a browser window.
31
+ trace (bool, optional): [--trace]. Capture a trace of each attempt, useful for debugging. Defaults to False.
32
+ keep_browser_open (bool, optional): [--keep-browser-open]. Keep the last browser open after execution for debugging. Defaults to False.
27
33
  """
28
- await assert_auth_enabled()
34
+ await assert_auth_enabled(auth_type="API")
29
35
 
30
36
  auth_session_input = await load_parameters(parameters) or {}
31
37
 
@@ -41,4 +47,6 @@ async def attempt__authsession__create(
41
47
  headless=headless,
42
48
  timeout=timeout_value,
43
49
  proxy=proxy,
50
+ trace=trace,
51
+ keep_browser_open=keep_browser_open,
44
52
  )
@@ -1,12 +1,12 @@
1
1
  import arguably
2
2
 
3
- from intuned_cli.utils.console import console
3
+ from intuned_cli.utils.help import print_help_and_exit
4
+ from intuned_cli.utils.wrapper import cli_command
4
5
 
5
6
 
6
7
  @arguably.command # type: ignore
8
+ @cli_command
7
9
  async def attempt():
8
10
  """Executes an Intuned attempt."""
9
11
 
10
- if arguably.is_target():
11
- console.print(" (-h/--help) for usage")
12
- exit(1)
12
+ print_help_and_exit()
@@ -0,0 +1,12 @@
1
+ import arguably
2
+
3
+ from intuned_cli.utils.help import print_help_and_exit
4
+ from intuned_cli.utils.wrapper import cli_command
5
+
6
+
7
+ @arguably.command # type: ignore
8
+ @cli_command
9
+ async def authsession():
10
+ """Manage Auth Sessions"""
11
+
12
+ print_help_and_exit()
@@ -0,0 +1,54 @@
1
+ import arguably
2
+ import pytimeparse # type: ignore
3
+
4
+ from intuned_cli.controller.authsession import execute_record_auth_session_cli
5
+ from intuned_cli.utils.auth_session_helpers import assert_auth_enabled
6
+ from intuned_cli.utils.auth_session_helpers import get_auth_session_recorder_parameters
7
+ from intuned_cli.utils.wrapper import cli_command
8
+
9
+
10
+ @arguably.command # type: ignore
11
+ @cli_command
12
+ async def authsession__record(
13
+ *,
14
+ id: str | None = None,
15
+ check_attempts: int = 1,
16
+ proxy: str | None = None,
17
+ timeout: str = "10 min",
18
+ headless: bool = False,
19
+ trace: bool = False,
20
+ keep_browser_open: bool = False,
21
+ ):
22
+ """Record a recorder-based auth session and then execute an AuthSession:Validate run to validate it
23
+
24
+ Args:
25
+ id (str | None, optional): ID of the auth session to record. If not provided, a new ID will be generated.
26
+ check_attempts (int, optional): [--check-attempts]. Number of attempts to check the auth session validity after it is created. Defaults to 1.
27
+ proxy (str | None, optional): [--proxy]. Proxy URL to use for recorder session and validation. Defaults to None.
28
+ timeout (str, optional): [--timeout]. Timeout for the auth session command - seconds or pytimeparse-formatted string. Defaults to "10 min".
29
+ headless (bool, optional): [--headless]. Run the auth session validation in headless mode (default: False). This will not open a browser window. The recorder will always be non-headless.
30
+ trace (bool, optional): [--trace]. Capture a trace of each attempt, useful for debugging. Defaults to False.
31
+ keep_browser_open (bool, optional): [--keep-browser-open]. Keep the last browser open after execution for debugging. Defaults to False.
32
+ """
33
+
34
+ await assert_auth_enabled(auth_type="MANUAL")
35
+
36
+ timeout_value = pytimeparse.parse(timeout) # type: ignore
37
+ if timeout_value is None:
38
+ raise ValueError(
39
+ f"Invalid timeout format: {timeout}. Please use a valid time format like '10 min' or '600 seconds'."
40
+ )
41
+
42
+ start_url, finish_url = await get_auth_session_recorder_parameters()
43
+
44
+ await execute_record_auth_session_cli(
45
+ start_url=start_url,
46
+ finish_url=finish_url,
47
+ id=id,
48
+ check_retries=check_attempts,
49
+ headless=headless,
50
+ proxy=proxy,
51
+ timeout=timeout_value,
52
+ trace=trace,
53
+ keep_browser_open=keep_browser_open,
54
+ )
@@ -1,9 +1,13 @@
1
1
  import arguably
2
2
 
3
3
  from intuned_cli.utils.console import console
4
+ from intuned_cli.utils.error import CLIExit
5
+ from intuned_cli.utils.help import print_help_and_exit
6
+ from intuned_cli.utils.wrapper import cli_command
4
7
 
5
8
 
6
9
  @arguably.command # type: ignore
10
+ @cli_command
7
11
  async def __root__(
8
12
  *,
9
13
  version: bool = False,
@@ -19,8 +23,6 @@ async def __root__(
19
23
 
20
24
  if version:
21
25
  console.print("1.0.0") # todo: better version handling
22
- exit(0)
26
+ raise CLIExit(0)
23
27
 
24
- if arguably.is_target() and not version:
25
- console.print(" (-h/--help) for usage")
26
- exit(1)
28
+ print_help_and_exit()
@@ -5,9 +5,11 @@ from intuned_cli.controller.save import validate_intuned_project
5
5
  from intuned_cli.controller.save import validate_project_name
6
6
  from intuned_cli.utils.backend import get_intuned_api_auth_credentials
7
7
  from intuned_cli.utils.error import CLIError
8
+ from intuned_cli.utils.wrapper import cli_command
8
9
 
9
10
 
10
11
  @arguably.command # type: ignore
12
+ @cli_command
11
13
  async def deploy(
12
14
  project_name: str | None = None,
13
15
  /,
@@ -3,9 +3,11 @@ from typing import Any
3
3
  import arguably
4
4
 
5
5
  from intuned_cli.utils.error import CLIError
6
+ from intuned_cli.utils.wrapper import cli_command
6
7
 
7
8
 
8
9
  @arguably.command # type: ignore
10
+ @cli_command
9
11
  async def init(
10
12
  *args: Any,
11
13
  ):
@@ -5,9 +5,11 @@ from intuned_cli.controller.api import AuthSessionInput
5
5
  from intuned_cli.controller.api import execute_run_api_cli
6
6
  from intuned_cli.utils.auth_session_helpers import assert_auth_consistent
7
7
  from intuned_cli.utils.auth_session_helpers import load_parameters
8
+ from intuned_cli.utils.wrapper import cli_command
8
9
 
9
10
 
10
11
  @arguably.command # type: ignore
12
+ @cli_command
11
13
  async def run__api(
12
14
  api_name: str,
13
15
  parameters: str,
@@ -22,8 +24,10 @@ async def run__api(
22
24
  timeout: str = "10 min",
23
25
  headless: bool = False,
24
26
  output_file: str | None = None,
27
+ trace: bool = False,
28
+ keep_browser_open: bool = False,
25
29
  ):
26
- """Execute san Intuned API run with parameters
30
+ """Execute an API run with parameters
27
31
 
28
32
  Args:
29
33
  api_name (str): Name of the API to run.
@@ -37,6 +41,8 @@ async def run__api(
37
41
  timeout (str, optional): [--timeout]. Timeout - seconds or pytimeparse-formatted string. Defaults to "10 min".
38
42
  headless (bool, optional): [--headless]. Run the API in headless mode (default: False). This will not open a browser window.
39
43
  output_file (str | None, optional): [-o/--output-file]. Output file path. Defaults to None.
44
+ trace (bool, optional): [--trace]. Capture a trace of each attempt, useful for debugging. Defaults to False.
45
+ keep_browser_open (bool, optional): [--keep-browser-open]. Keep the last browser open after execution for debugging. Defaults to False.
40
46
  """
41
47
  auth_session_auto_recreate = not no_auth_session_auto_recreate
42
48
 
@@ -66,4 +72,6 @@ async def run__api(
66
72
  timeout=timeout_value,
67
73
  headless=headless,
68
74
  output_file=output_file,
75
+ trace=trace,
76
+ keep_browser_open=keep_browser_open,
69
77
  )
@@ -1,12 +1,12 @@
1
1
  import arguably
2
2
 
3
- from intuned_cli.utils.console import console
3
+ from intuned_cli.utils.help import print_help_and_exit
4
+ from intuned_cli.utils.wrapper import cli_command
4
5
 
5
6
 
6
7
  @arguably.command # type: ignore
8
+ @cli_command
7
9
  async def run__authsession():
8
10
  """Executes an Intuned authsession run"""
9
11
 
10
- if arguably.is_target():
11
- console.print(" (-h/--help) for usage")
12
- exit(1)
12
+ print_help_and_exit()
@@ -1,13 +1,17 @@
1
+ from functools import WRAPPER_ASSIGNMENTS
2
+ from functools import wraps
3
+
1
4
  import arguably
2
5
  import pytimeparse # type: ignore
3
6
 
4
7
  from intuned_cli.controller.authsession import execute_run_create_auth_session_cli
5
8
  from intuned_cli.utils.auth_session_helpers import assert_auth_enabled
6
9
  from intuned_cli.utils.auth_session_helpers import load_parameters
10
+ from intuned_cli.utils.wrapper import cli_command
7
11
 
8
12
 
9
- @arguably.command # type: ignore
10
- async def run__authsession__create(
13
+ @cli_command
14
+ async def _run_auth_session_create_impl(
11
15
  parameters: str,
12
16
  /,
13
17
  *,
@@ -17,8 +21,10 @@ async def run__authsession__create(
17
21
  proxy: str | None = None,
18
22
  timeout: str = "10 min",
19
23
  headless: bool = False,
24
+ trace: bool = False,
25
+ keep_browser_open: bool = False,
20
26
  ):
21
- """Create a new auth session
27
+ """Execute an AuthSession:Create run to create an auth session
22
28
 
23
29
  Args:
24
30
  parameters (str): Parameters for the auth session command
@@ -28,8 +34,11 @@ async def run__authsession__create(
28
34
  proxy (str | None, optional): [--proxy]. Proxy URL to use for the auth session command. Defaults to None.
29
35
  timeout (str, optional): [--timeout]. Timeout for the auth session command - seconds or pytimeparse-formatted string. Defaults to "10 min".
30
36
  headless (bool, optional): [--headless]. Run the API in headless mode (default: False). This will not open a browser window.
37
+ trace (bool, optional): [--trace]. Capture a trace of each attempt, useful for debugging. Defaults to False.
38
+ keep_browser_open (bool, optional): [--keep-browser-open]. Keep the last browser open after execution for debugging. Defaults to False.
31
39
  """
32
- await assert_auth_enabled()
40
+
41
+ await assert_auth_enabled(auth_type="API")
33
42
 
34
43
  auth_session_input = await load_parameters(parameters) or {}
35
44
 
@@ -47,4 +56,25 @@ async def run__authsession__create(
47
56
  headless=headless,
48
57
  proxy=proxy,
49
58
  timeout=timeout_value,
59
+ trace=trace,
60
+ keep_browser_open=keep_browser_open,
50
61
  )
62
+
63
+
64
+ # @wraps will give the wrapped function all the properties of the original function (parameter types, docstring, name, etc...). We want to do that for everything except the name, to register it as two different commands
65
+ @arguably.command # type: ignore
66
+ @wraps(_run_auth_session_create_impl, (a for a in WRAPPER_ASSIGNMENTS if a != "__name__"))
67
+ async def run__authsession__create(
68
+ *args, # type: ignore
69
+ **kwargs, # type: ignore
70
+ ):
71
+ return await _run_auth_session_create_impl(*args, **kwargs) # type: ignore
72
+
73
+
74
+ @arguably.command # type: ignore
75
+ @wraps(_run_auth_session_create_impl, (a for a in WRAPPER_ASSIGNMENTS if a != "__name__"))
76
+ async def authsession__create(
77
+ *args, # type: ignore
78
+ **kwargs, # type: ignore
79
+ ):
80
+ return await _run_auth_session_create_impl(*args, **kwargs) # type: ignore
@@ -1,13 +1,17 @@
1
+ from functools import WRAPPER_ASSIGNMENTS
2
+ from functools import wraps
3
+
1
4
  import arguably
2
5
  import pytimeparse # type: ignore
3
6
 
4
7
  from intuned_cli.controller.authsession import execute_run_update_auth_session_cli
5
8
  from intuned_cli.utils.auth_session_helpers import assert_auth_enabled
6
9
  from intuned_cli.utils.auth_session_helpers import load_parameters
10
+ from intuned_cli.utils.wrapper import cli_command
7
11
 
8
12
 
9
- @arguably.command # type: ignore
10
- async def run__authsession__update(
13
+ @cli_command
14
+ async def _run_update_authsession_impl(
11
15
  id: str,
12
16
  /,
13
17
  *,
@@ -17,8 +21,10 @@ async def run__authsession__update(
17
21
  proxy: str | None = None,
18
22
  timeout: str = "10 min",
19
23
  headless: bool = False,
24
+ trace: bool = False,
25
+ keep_browser_open: bool = False,
20
26
  ):
21
- """Update an existing auth session
27
+ """Execute an AuthSession:Update run to update an existing auth session
22
28
 
23
29
  Args:
24
30
  id (str): ID of the auth session to update
@@ -28,8 +34,10 @@ async def run__authsession__update(
28
34
  proxy (str | None, optional): [--proxy]. Proxy URL to use for the auth session command. Defaults to None.
29
35
  timeout (str, optional): [--timeout]. Timeout for the auth session command - seconds or pytimeparse-formatted string. Defaults to "10 min".
30
36
  headless (bool, optional): [--headless]. Run the API in headless mode (default: False). This will not open a browser window.
37
+ trace (bool, optional): [--trace]. Capture a trace of each attempt, useful for debugging. Defaults to False.
38
+ keep_browser_open (bool, optional): [--keep-browser-open]. Keep the last browser open after execution for debugging. Defaults to False.
31
39
  """
32
- await assert_auth_enabled()
40
+ await assert_auth_enabled(auth_type="API")
33
41
 
34
42
  auth_session_input = None
35
43
  if parameters:
@@ -49,4 +57,25 @@ async def run__authsession__update(
49
57
  headless=headless,
50
58
  proxy=proxy,
51
59
  timeout=timeout_value,
60
+ trace=trace,
61
+ keep_browser_open=keep_browser_open,
52
62
  )
63
+
64
+
65
+ # @wraps will give the wrapped function all the properties of the original function (parameter types, docstring, name, etc...). We want to do that for everything except the name, to register it as two different commands
66
+ @arguably.command # type: ignore
67
+ @wraps(_run_update_authsession_impl, (a for a in WRAPPER_ASSIGNMENTS if a != "__name__"))
68
+ async def run_authsession__update(
69
+ *args, # type: ignore
70
+ **kwargs, # type: ignore
71
+ ):
72
+ return await _run_update_authsession_impl(*args, **kwargs) # type: ignore
73
+
74
+
75
+ @arguably.command # type: ignore
76
+ @wraps(_run_update_authsession_impl, (a for a in WRAPPER_ASSIGNMENTS if a != "__name__"))
77
+ async def authsession__update(
78
+ *args, # type: ignore
79
+ **kwargs, # type: ignore
80
+ ):
81
+ return await _run_update_authsession_impl(*args, **kwargs) # type: ignore
@@ -1,12 +1,16 @@
1
+ from functools import WRAPPER_ASSIGNMENTS
2
+ from functools import wraps
3
+
1
4
  import arguably
2
5
  import pytimeparse # type: ignore
3
6
 
4
7
  from intuned_cli.controller.authsession import execute_run_validate_auth_session_cli
5
8
  from intuned_cli.utils.auth_session_helpers import assert_auth_enabled
9
+ from intuned_cli.utils.wrapper import cli_command
6
10
 
7
11
 
8
- @arguably.command # type: ignore
9
- async def run__authsession__validate(
12
+ @cli_command
13
+ async def _run_validate_authsession_impl(
10
14
  id: str,
11
15
  /,
12
16
  *,
@@ -16,8 +20,10 @@ async def run__authsession__validate(
16
20
  timeout: str = "10 min",
17
21
  no_auto_recreate: bool = False,
18
22
  headless: bool = False,
23
+ trace: bool = False,
24
+ keep_browser_open: bool = False,
19
25
  ):
20
- """Validate an existing auth session
26
+ """Execute an AuthSession:Validate run to validate an auth session
21
27
 
22
28
  Args:
23
29
  id (str): ID of the auth session to validate
@@ -27,6 +33,8 @@ async def run__authsession__validate(
27
33
  timeout (str, optional): [--timeout]. Timeout for the auth session command - seconds or pytimeparse-formatted string. Defaults to "10 min".
28
34
  no_auto_recreate (bool, optional): [--no-auto-recreate]. Disable auto recreation of the auth session if it is invalid. Defaults to False.
29
35
  headless (bool, optional): [--headless]. Run the API in headless mode (default: False). This will not open a browser window.
36
+ trace (bool, optional): [--trace]. Capture a trace of each attempt, useful for debugging. Defaults to False.
37
+ keep_browser_open (bool, optional): [--keep-browser-open]. Keep the last browser open after execution for debugging. Defaults to False.
30
38
  """
31
39
  await assert_auth_enabled()
32
40
 
@@ -46,4 +54,25 @@ async def run__authsession__validate(
46
54
  headless=headless,
47
55
  proxy=proxy,
48
56
  timeout=timeout_value,
57
+ trace=trace,
58
+ keep_browser_open=keep_browser_open,
49
59
  )
60
+
61
+
62
+ # @wraps will give the wrapped function all the properties of the original function (parameter types, docstring, name, etc...). We want to do that for everything except the name, to register it as two different commands
63
+ @arguably.command # type: ignore
64
+ @wraps(_run_validate_authsession_impl, (a for a in WRAPPER_ASSIGNMENTS if a != "__name__"))
65
+ async def run__authsession__validate(
66
+ *args, # type: ignore
67
+ **kwargs, # type: ignore
68
+ ):
69
+ return await _run_validate_authsession_impl(*args, **kwargs) # type: ignore
70
+
71
+
72
+ @arguably.command # type: ignore
73
+ @wraps(_run_validate_authsession_impl, (a for a in WRAPPER_ASSIGNMENTS if a != "__name__"))
74
+ async def authsession__validate(
75
+ *args, # type: ignore
76
+ **kwargs, # type: ignore
77
+ ):
78
+ return await _run_validate_authsession_impl(*args, **kwargs) # type: ignore
@@ -1,12 +1,12 @@
1
1
  import arguably
2
2
 
3
- from intuned_cli.utils.console import console
3
+ from intuned_cli.utils.help import print_help_and_exit
4
+ from intuned_cli.utils.wrapper import cli_command
4
5
 
5
6
 
6
7
  @arguably.command # type: ignore
8
+ @cli_command
7
9
  async def run():
8
10
  """Executes an Intuned run."""
9
11
 
10
- if arguably.is_target():
11
- console.print(" (-h/--help) for usage")
12
- exit(1)
12
+ print_help_and_exit()
@@ -5,9 +5,11 @@ from intuned_cli.controller.save import validate_intuned_project
5
5
  from intuned_cli.controller.save import validate_project_name
6
6
  from intuned_cli.utils.backend import get_intuned_api_auth_credentials
7
7
  from intuned_cli.utils.error import CLIError
8
+ from intuned_cli.utils.wrapper import cli_command
8
9
 
9
10
 
10
11
  @arguably.command # type: ignore
12
+ @cli_command
11
13
  async def save(
12
14
  project_name: str | None = None,
13
15
  /,