intuned-runtime 1.0.0__py3-none-any.whl → 1.1.1__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.
- intuned_cli/__init__.py +40 -0
- intuned_cli/commands/__init__.py +18 -0
- intuned_cli/commands/attempt_api_command.py +51 -0
- intuned_cli/commands/attempt_authsession_check_command.py +38 -0
- intuned_cli/commands/attempt_authsession_command.py +12 -0
- intuned_cli/commands/attempt_authsession_create_command.py +44 -0
- intuned_cli/commands/attempt_command.py +12 -0
- intuned_cli/commands/command.py +26 -0
- intuned_cli/commands/deploy_command.py +47 -0
- intuned_cli/commands/init_command.py +21 -0
- intuned_cli/commands/run_api_command.py +69 -0
- intuned_cli/commands/run_authsession_command.py +12 -0
- intuned_cli/commands/run_authsession_create_command.py +50 -0
- intuned_cli/commands/run_authsession_update_command.py +52 -0
- intuned_cli/commands/run_authsession_validate_command.py +49 -0
- intuned_cli/commands/run_command.py +12 -0
- intuned_cli/constants/__init__.py +1 -0
- intuned_cli/constants/readme.py +134 -0
- intuned_cli/controller/__test__/__init__.py +0 -0
- intuned_cli/controller/__test__/test_api.py +529 -0
- intuned_cli/controller/__test__/test_authsession.py +907 -0
- intuned_cli/controller/api.py +212 -0
- intuned_cli/controller/authsession.py +458 -0
- intuned_cli/controller/deploy.py +352 -0
- intuned_cli/controller/init.py +97 -0
- intuned_cli/types.py +33 -0
- intuned_cli/utils/api_helpers.py +32 -0
- intuned_cli/utils/auth_session_helpers.py +57 -0
- intuned_cli/utils/backend.py +5 -0
- intuned_cli/utils/confirmation.py +0 -0
- intuned_cli/utils/console.py +6 -0
- intuned_cli/utils/error.py +27 -0
- intuned_cli/utils/exclusions.py +40 -0
- intuned_cli/utils/get_auth_parameters.py +18 -0
- intuned_cli/utils/import_function.py +15 -0
- intuned_cli/utils/timeout.py +25 -0
- {cli → intuned_internal_cli}/__init__.py +1 -1
- {cli → intuned_internal_cli}/commands/__init__.py +2 -0
- {cli → intuned_internal_cli}/commands/ai_source/deploy.py +1 -1
- {cli → intuned_internal_cli}/commands/browser/save_state.py +2 -2
- {cli → intuned_internal_cli}/commands/project/auth_session/load.py +2 -2
- {cli → intuned_internal_cli}/commands/project/type_check.py +39 -32
- intuned_internal_cli/commands/root.py +15 -0
- {intuned_runtime-1.0.0.dist-info → intuned_runtime-1.1.1.dist-info}/METADATA +5 -1
- intuned_runtime-1.1.1.dist-info/RECORD +99 -0
- intuned_runtime-1.1.1.dist-info/entry_points.txt +4 -0
- runtime/__init__.py +2 -1
- runtime/backend_functions/_call_backend_function.py +0 -5
- runtime/browser/__init__.py +5 -2
- runtime/browser/helpers.py +21 -0
- runtime/browser/launch_browser.py +31 -0
- runtime/browser/launch_camoufox.py +61 -0
- runtime/browser/launch_chromium.py +64 -61
- runtime/browser/storage_state.py +11 -12
- runtime/env.py +4 -0
- runtime/errors/run_api_errors.py +14 -10
- runtime/run/playwright_constructs.py +6 -5
- runtime/run/pydantic_encoder.py +15 -0
- runtime/run/run_api.py +5 -4
- runtime/types/run_types.py +16 -0
- intuned_runtime-1.0.0.dist-info/RECORD +0 -58
- intuned_runtime-1.0.0.dist-info/entry_points.txt +0 -3
- {cli → intuned_internal_cli}/commands/ai_source/__init__.py +0 -0
- {cli → intuned_internal_cli}/commands/ai_source/ai_source.py +0 -0
- {cli → intuned_internal_cli}/commands/browser/__init__.py +0 -0
- {cli → intuned_internal_cli}/commands/init.py +0 -0
- {cli → intuned_internal_cli}/commands/project/__init__.py +0 -0
- {cli → intuned_internal_cli}/commands/project/auth_session/__init__.py +0 -0
- {cli → intuned_internal_cli}/commands/project/auth_session/check.py +0 -0
- {cli → intuned_internal_cli}/commands/project/auth_session/create.py +0 -0
- {cli → intuned_internal_cli}/commands/project/project.py +0 -0
- {cli → intuned_internal_cli}/commands/project/run.py +0 -0
- {cli → intuned_internal_cli}/commands/project/run_interface.py +0 -0
- {cli → intuned_internal_cli}/commands/project/upgrade.py +0 -0
- {cli → intuned_internal_cli}/commands/publish_packages.py +0 -0
- {cli → intuned_internal_cli}/logger.py +0 -0
- {cli → intuned_internal_cli}/utils/ai_source_project.py +0 -0
- {cli → intuned_internal_cli}/utils/code_tree.py +0 -0
- {cli → intuned_internal_cli}/utils/run_apis.py +0 -0
- {cli → intuned_internal_cli}/utils/unix_socket.py +0 -0
- {intuned_runtime-1.0.0.dist-info → intuned_runtime-1.1.1.dist-info}/LICENSE +0 -0
- {intuned_runtime-1.0.0.dist-info → intuned_runtime-1.1.1.dist-info}/WHEEL +0 -0
intuned_cli/__init__.py
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
import sys
|
2
|
+
|
3
|
+
import arguably
|
4
|
+
from dotenv import find_dotenv
|
5
|
+
from dotenv import load_dotenv
|
6
|
+
|
7
|
+
from intuned_cli.utils.console import console
|
8
|
+
from intuned_cli.utils.error import CLIError
|
9
|
+
from intuned_cli.utils.error import log_automation_error
|
10
|
+
from runtime.context.context import IntunedContext
|
11
|
+
from runtime.errors.run_api_errors import AutomationError
|
12
|
+
|
13
|
+
from . import commands
|
14
|
+
|
15
|
+
|
16
|
+
def run():
|
17
|
+
dotenv = find_dotenv(usecwd=True)
|
18
|
+
if dotenv:
|
19
|
+
load_dotenv(dotenv, override=True)
|
20
|
+
try:
|
21
|
+
with IntunedContext():
|
22
|
+
arguably.run(name="intuned")
|
23
|
+
sys.exit(0)
|
24
|
+
except CLIError as e:
|
25
|
+
if e.auto_color:
|
26
|
+
console.print(f"[bold red]{e.message}[/bold red]")
|
27
|
+
else:
|
28
|
+
console.print(e.message)
|
29
|
+
except AutomationError as e:
|
30
|
+
log_automation_error(e)
|
31
|
+
except KeyboardInterrupt:
|
32
|
+
console.print("[bold red]Aborted[/bold red]")
|
33
|
+
except Exception as e:
|
34
|
+
console.print(
|
35
|
+
f"[red][bold]An error occurred: [/bold]{e}\n[bold]Please report this issue to the Intuned team.[/bold]"
|
36
|
+
)
|
37
|
+
sys.exit(1)
|
38
|
+
|
39
|
+
|
40
|
+
__all__ = ["commands", "run"]
|
@@ -0,0 +1,18 @@
|
|
1
|
+
from .attempt_api_command import attempt__api as attempt__api # type: ignore
|
2
|
+
from .attempt_authsession_check_command import (
|
3
|
+
attempt__authsession__check as attempt__authsession__check, # type: ignore
|
4
|
+
)
|
5
|
+
from .attempt_authsession_command import attempt__authsession as attempt__authsession # type: ignore
|
6
|
+
from .attempt_authsession_create_command import (
|
7
|
+
attempt__authsession__create as attempt__authsession__create, # type: ignore
|
8
|
+
)
|
9
|
+
from .attempt_command import attempt as attempt # type: ignore
|
10
|
+
from .command import __root__ as __root__ # type: ignore
|
11
|
+
from .deploy_command import deploy as deploy # type: ignore
|
12
|
+
from .init_command import init as init # type: ignore
|
13
|
+
from .run_api_command import run__api as run__api # type: ignore
|
14
|
+
from .run_authsession_command import run__authsession as run__authsession # type: ignore
|
15
|
+
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
|
17
|
+
from .run_authsession_validate_command import run__authsession__validate as run__authsession__validate # type: ignore
|
18
|
+
from .run_command import run as run # type: ignore
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import arguably
|
2
|
+
import pytimeparse # type: ignore
|
3
|
+
|
4
|
+
from intuned_cli.controller.api import execute_attempt_api_cli
|
5
|
+
from intuned_cli.utils.auth_session_helpers import assert_auth_consistent
|
6
|
+
from intuned_cli.utils.auth_session_helpers import load_parameters
|
7
|
+
|
8
|
+
|
9
|
+
@arguably.command # type: ignore
|
10
|
+
async def attempt__api(
|
11
|
+
api_name: str,
|
12
|
+
parameters: str,
|
13
|
+
/,
|
14
|
+
*,
|
15
|
+
auth_session: str | None = None,
|
16
|
+
proxy: str | None = None,
|
17
|
+
timeout: str = "10 min",
|
18
|
+
headless: bool = False,
|
19
|
+
output_file: str | None = None,
|
20
|
+
):
|
21
|
+
"""Executes an Intuned API attempt with parameters
|
22
|
+
|
23
|
+
Args:
|
24
|
+
api_name (str): Name of the API.
|
25
|
+
parameters (str): Path to JSON file containing API parameters or the parameters as a JSON string.
|
26
|
+
auth_session (str | None, optional): [-a/--auth-session]. ID of the auth session to use for the API. This is expected to be in ./auth-session-instances/<id>
|
27
|
+
proxy (str | None, optional): [--proxy]. Proxy URL to use. Defaults to None.
|
28
|
+
timeout (str, optional): [--timeout]. Timeout - milliseconds or pytimeparse-formatted string. Defaults to "10 min".
|
29
|
+
headless (bool, optional): [--headless]. Run the API in headless mode (default: False). This will not open a browser window.
|
30
|
+
output_file (str | None, optional): [-o/--output-file]. Output file path. Defaults to None.
|
31
|
+
"""
|
32
|
+
|
33
|
+
await assert_auth_consistent(auth_session)
|
34
|
+
|
35
|
+
input_data = await load_parameters(parameters)
|
36
|
+
|
37
|
+
timeout_value = pytimeparse.parse(timeout) # type: ignore
|
38
|
+
if timeout_value is None:
|
39
|
+
raise ValueError(
|
40
|
+
f"Invalid timeout format: {timeout}. Please use a valid time format like '10 min' or '600 seconds'."
|
41
|
+
)
|
42
|
+
|
43
|
+
await execute_attempt_api_cli(
|
44
|
+
api_name=api_name,
|
45
|
+
input_data=input_data,
|
46
|
+
proxy=proxy,
|
47
|
+
auth_session_id=auth_session,
|
48
|
+
timeout=timeout_value,
|
49
|
+
headless=headless,
|
50
|
+
output_file=output_file,
|
51
|
+
)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import arguably
|
2
|
+
import pytimeparse # type: ignore
|
3
|
+
|
4
|
+
from intuned_cli.controller.authsession import execute_attempt_check_auth_session_cli
|
5
|
+
from intuned_cli.utils.auth_session_helpers import assert_auth_enabled
|
6
|
+
|
7
|
+
|
8
|
+
@arguably.command # type: ignore
|
9
|
+
async def attempt__authsession__check(
|
10
|
+
id: str,
|
11
|
+
/,
|
12
|
+
*,
|
13
|
+
proxy: str | None = None,
|
14
|
+
timeout: str = "10 min",
|
15
|
+
headless: bool = False,
|
16
|
+
):
|
17
|
+
"""Check an existing auth session
|
18
|
+
|
19
|
+
Args:
|
20
|
+
id (str): ID of the auth session to check
|
21
|
+
proxy (str | None, optional): [--proxy]. Proxy URL to use for the auth session command. Defaults to None.
|
22
|
+
timeout (str, optional): [--timeout]. Timeout for the auth session command - milliseconds or pytimeparse-formatted string. Defaults to "10 min".
|
23
|
+
headless (bool, optional): [--headless]. Run the API in headless mode (default: False). This will not open a browser window.
|
24
|
+
"""
|
25
|
+
await assert_auth_enabled()
|
26
|
+
|
27
|
+
timeout_value = pytimeparse.parse(timeout) # type: ignore
|
28
|
+
if timeout_value is None:
|
29
|
+
raise ValueError(
|
30
|
+
f"Invalid timeout format: {timeout}. Please use a valid time format like '10 min' or '600 seconds'."
|
31
|
+
)
|
32
|
+
|
33
|
+
await execute_attempt_check_auth_session_cli(
|
34
|
+
id=id,
|
35
|
+
headless=headless,
|
36
|
+
timeout=timeout_value,
|
37
|
+
proxy=proxy,
|
38
|
+
)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import arguably
|
2
|
+
|
3
|
+
from intuned_cli.utils.console import console
|
4
|
+
|
5
|
+
|
6
|
+
@arguably.command # type: ignore
|
7
|
+
async def attempt__authsession():
|
8
|
+
"""Execute san Intuned authsession attempt"""
|
9
|
+
|
10
|
+
if arguably.is_target():
|
11
|
+
console.print(" (-h/--help) for usage")
|
12
|
+
exit(1)
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import arguably
|
2
|
+
import pytimeparse # type: ignore
|
3
|
+
|
4
|
+
from intuned_cli.controller.authsession import execute_attempt_create_auth_session_cli
|
5
|
+
from intuned_cli.utils.auth_session_helpers import assert_auth_enabled
|
6
|
+
from intuned_cli.utils.auth_session_helpers import load_parameters
|
7
|
+
|
8
|
+
|
9
|
+
@arguably.command # type: ignore
|
10
|
+
async def attempt__authsession__create(
|
11
|
+
parameters: str,
|
12
|
+
/,
|
13
|
+
*,
|
14
|
+
id: str | None = None,
|
15
|
+
proxy: str | None = None,
|
16
|
+
timeout: str = "10 min",
|
17
|
+
headless: bool = False,
|
18
|
+
):
|
19
|
+
"""Create a new auth session
|
20
|
+
|
21
|
+
Args:
|
22
|
+
parameters (str): Parameters for the auth session command
|
23
|
+
id (str | None, optional): [--id]. ID of the auth session to use for the command. Defaults to ./auth-session-instances/[current timestamp].json.
|
24
|
+
proxy (str | None, optional): [--proxy]. Proxy URL to use for the auth session command. Defaults to None.
|
25
|
+
timeout (str, optional): [--timeout]. Timeout for the auth session command - milliseconds or pytimeparse-formatted string. Defaults to "10 min".
|
26
|
+
headless (bool, optional): [--headless]. Run the API in headless mode (default: False). This will not open a browser window.
|
27
|
+
"""
|
28
|
+
await assert_auth_enabled()
|
29
|
+
|
30
|
+
auth_session_input = await load_parameters(parameters) or {}
|
31
|
+
|
32
|
+
timeout_value = pytimeparse.parse(timeout) # type: ignore
|
33
|
+
if timeout_value is None:
|
34
|
+
raise ValueError(
|
35
|
+
f"Invalid timeout format: {timeout}. Please use a valid time format like '10 min' or '600 seconds'."
|
36
|
+
)
|
37
|
+
|
38
|
+
await execute_attempt_create_auth_session_cli(
|
39
|
+
id=id,
|
40
|
+
input_data=auth_session_input,
|
41
|
+
headless=headless,
|
42
|
+
timeout=timeout_value,
|
43
|
+
proxy=proxy,
|
44
|
+
)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import arguably
|
2
|
+
|
3
|
+
from intuned_cli.utils.console import console
|
4
|
+
|
5
|
+
|
6
|
+
@arguably.command # type: ignore
|
7
|
+
async def __root__(
|
8
|
+
*,
|
9
|
+
version: bool = False,
|
10
|
+
):
|
11
|
+
"""Intuned CLI to initialize, develop and deploy Intuned projects.
|
12
|
+
|
13
|
+
This command is the entry point for the Intuned CLI. It provides various subcommands
|
14
|
+
for managing Intuned projects, including initialization, development, and deployment.
|
15
|
+
|
16
|
+
Args:
|
17
|
+
version (bool, optional): [-v/--version] Show version information. Defaults to False.
|
18
|
+
"""
|
19
|
+
|
20
|
+
if version:
|
21
|
+
console.print("1.0.0") # todo: better version handling
|
22
|
+
exit(0)
|
23
|
+
|
24
|
+
if arguably.is_target() and not version:
|
25
|
+
console.print(" (-h/--help) for usage")
|
26
|
+
exit(1)
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import arguably
|
2
|
+
|
3
|
+
from intuned_cli.controller.deploy import deploy_project
|
4
|
+
from intuned_cli.controller.deploy import get_intuned_api_auth_credentials
|
5
|
+
from intuned_cli.controller.deploy import validate_intuned_project
|
6
|
+
from intuned_cli.controller.deploy import validate_project_name
|
7
|
+
from intuned_cli.utils.error import CLIError
|
8
|
+
|
9
|
+
|
10
|
+
@arguably.command # type: ignore
|
11
|
+
async def deploy(
|
12
|
+
project_name: str | None = None,
|
13
|
+
/,
|
14
|
+
*,
|
15
|
+
workspace_id: str | None = None,
|
16
|
+
api_key: str | None = None,
|
17
|
+
):
|
18
|
+
"""Deploys the application.
|
19
|
+
|
20
|
+
Args:
|
21
|
+
project_name (str | None, optional): The name of the project to deploy.
|
22
|
+
workspace_id (str | None, optional): The ID of the workspace to deploy to.
|
23
|
+
api_key (str | None, optional): The API key to use for authentication.
|
24
|
+
"""
|
25
|
+
try:
|
26
|
+
intuned_json = await validate_intuned_project()
|
27
|
+
except CLIError as e:
|
28
|
+
raise CLIError(
|
29
|
+
f"[bold red]Project to be deployed is not a valid Intuned project:[/bold red][bright_red] {e}[/bright_red]\n",
|
30
|
+
auto_color=False,
|
31
|
+
) from e
|
32
|
+
|
33
|
+
project_name = project_name or intuned_json.project_name
|
34
|
+
if not project_name:
|
35
|
+
raise CLIError("Project name is required")
|
36
|
+
|
37
|
+
validate_project_name(project_name)
|
38
|
+
|
39
|
+
workspace_id, api_key = await get_intuned_api_auth_credentials(
|
40
|
+
intuned_json=intuned_json, workspace_id=workspace_id, api_key=api_key
|
41
|
+
)
|
42
|
+
|
43
|
+
await deploy_project(
|
44
|
+
project_name=project_name,
|
45
|
+
workspace_id=workspace_id,
|
46
|
+
api_key=api_key,
|
47
|
+
)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import arguably
|
2
|
+
|
3
|
+
from intuned_cli.controller.init import check_empty_directory
|
4
|
+
from intuned_cli.controller.init import python_template_name
|
5
|
+
from intuned_cli.controller.init import write_project_from_file_tree
|
6
|
+
|
7
|
+
|
8
|
+
@arguably.command # type: ignore
|
9
|
+
async def init():
|
10
|
+
"""
|
11
|
+
Initializes current app, creating pyproject.toml and Intuned.json files. Will ask for confirmation before overwriting existing files.
|
12
|
+
|
13
|
+
Args:
|
14
|
+
template_name (str | None): Name of the template to use.
|
15
|
+
|
16
|
+
Returns:
|
17
|
+
None
|
18
|
+
"""
|
19
|
+
is_target_directory_empty = await check_empty_directory()
|
20
|
+
|
21
|
+
await write_project_from_file_tree(python_template_name, is_target_directory_empty)
|
@@ -0,0 +1,69 @@
|
|
1
|
+
import arguably
|
2
|
+
import pytimeparse # type: ignore
|
3
|
+
|
4
|
+
from intuned_cli.controller.api import AuthSessionInput
|
5
|
+
from intuned_cli.controller.api import execute_run_api_cli
|
6
|
+
from intuned_cli.utils.auth_session_helpers import assert_auth_consistent
|
7
|
+
from intuned_cli.utils.auth_session_helpers import load_parameters
|
8
|
+
|
9
|
+
|
10
|
+
@arguably.command # type: ignore
|
11
|
+
async def run__api(
|
12
|
+
api_name: str,
|
13
|
+
parameters: str,
|
14
|
+
/,
|
15
|
+
*,
|
16
|
+
auth_session: str | None = None,
|
17
|
+
retries: int = 1,
|
18
|
+
proxy: str | None = None,
|
19
|
+
no_auth_session_auto_recreate: bool = False,
|
20
|
+
auth_session_check_attempts: int = 1,
|
21
|
+
auth_session_create_attempts: int = 1,
|
22
|
+
timeout: str = "10 min",
|
23
|
+
headless: bool = False,
|
24
|
+
output_file: str | None = None,
|
25
|
+
):
|
26
|
+
"""Execute san Intuned API run with parameters
|
27
|
+
|
28
|
+
Args:
|
29
|
+
api_name (str): Name of the API to run.
|
30
|
+
parameters (str): Path to the JSON file containing API parameters OR the parameters as a JSON string.
|
31
|
+
auth_session (str | None, optional): [-a/--auth-session]. ID of the auth session to use for the API. This is expected to be in ./auth-session-instances/<id>.
|
32
|
+
retries (int, optional): [--retries]. Number of retries for the API call. Defaults to 1.
|
33
|
+
proxy (str | None, optional): [--proxy]. Proxy URL to use. Defaults to None.
|
34
|
+
no_auth_session_auto_recreate (bool, optional): [--no-auth-session-auto-recreate]. Disable auto recreate for auth session. Defaults to False.
|
35
|
+
auth_session_check_attempts (int, optional): [--auth-session-check-attempts]. Auth session check attempts. Defaults to 1.
|
36
|
+
auth_session_create_attempts (int, optional): [--auth-session-create-attempts]. Auth session create attempts. Defaults to 1.
|
37
|
+
timeout (str, optional): [--timeout]. Timeout - milliseconds or pytimeparse-formatted string. Defaults to "10 min".
|
38
|
+
headless (bool, optional): [--headless]. Run the API in headless mode (default: False). This will not open a browser window.
|
39
|
+
output_file (str | None, optional): [-o/--output-file]. Output file path. Defaults to None.
|
40
|
+
"""
|
41
|
+
auth_session_auto_recreate = not no_auth_session_auto_recreate
|
42
|
+
|
43
|
+
await assert_auth_consistent(auth_session)
|
44
|
+
|
45
|
+
input_data = await load_parameters(parameters)
|
46
|
+
|
47
|
+
timeout_value = pytimeparse.parse(timeout) # type: ignore
|
48
|
+
if timeout_value is None:
|
49
|
+
raise ValueError(
|
50
|
+
f"Invalid timeout format: {timeout}. Please use a valid time format like '10 min' or '600 seconds'."
|
51
|
+
)
|
52
|
+
|
53
|
+
await execute_run_api_cli(
|
54
|
+
api_name=api_name,
|
55
|
+
input_data=input_data,
|
56
|
+
retries=retries,
|
57
|
+
proxy=proxy,
|
58
|
+
auth_session=AuthSessionInput(
|
59
|
+
id=auth_session,
|
60
|
+
auto_recreate=auth_session_auto_recreate,
|
61
|
+
check_retries=auth_session_check_attempts,
|
62
|
+
create_retries=auth_session_create_attempts,
|
63
|
+
)
|
64
|
+
if auth_session
|
65
|
+
else None,
|
66
|
+
timeout=timeout_value,
|
67
|
+
headless=headless,
|
68
|
+
output_file=output_file,
|
69
|
+
)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import arguably
|
2
|
+
|
3
|
+
from intuned_cli.utils.console import console
|
4
|
+
|
5
|
+
|
6
|
+
@arguably.command # type: ignore
|
7
|
+
async def run__authsession():
|
8
|
+
"""Executes an Intuned authsession run"""
|
9
|
+
|
10
|
+
if arguably.is_target():
|
11
|
+
console.print(" (-h/--help) for usage")
|
12
|
+
exit(1)
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import arguably
|
2
|
+
import pytimeparse # type: ignore
|
3
|
+
|
4
|
+
from intuned_cli.controller.authsession import execute_run_create_auth_session_cli
|
5
|
+
from intuned_cli.utils.auth_session_helpers import assert_auth_enabled
|
6
|
+
from intuned_cli.utils.auth_session_helpers import load_parameters
|
7
|
+
|
8
|
+
|
9
|
+
@arguably.command # type: ignore
|
10
|
+
async def run__authsession__create(
|
11
|
+
parameters: str,
|
12
|
+
/,
|
13
|
+
*,
|
14
|
+
id: str | None = None,
|
15
|
+
check_attempts: int = 1,
|
16
|
+
create_attempts: int = 1,
|
17
|
+
proxy: str | None = None,
|
18
|
+
timeout: str = "10 min",
|
19
|
+
headless: bool = False,
|
20
|
+
):
|
21
|
+
"""Create a new auth session
|
22
|
+
|
23
|
+
Args:
|
24
|
+
parameters (str): Parameters for the auth session command
|
25
|
+
id (str | None, optional): [--id]. ID of the auth session to use for the command. Defaults to auth-session-[current timestamp].
|
26
|
+
check_attempts (int, optional): [--check-attempts]. Number of attempts to check the auth session validity. Defaults to 1.
|
27
|
+
create_attempts (int, optional): [--create-attempts]. Number of attempts to create a new auth session if it is invalid. Defaults to 1.
|
28
|
+
proxy (str | None, optional): [--proxy]. Proxy URL to use for the auth session command. Defaults to None.
|
29
|
+
timeout (str, optional): [--timeout]. Timeout for the auth session command - milliseconds or pytimeparse-formatted string. Defaults to "10 min".
|
30
|
+
headless (bool, optional): [--headless]. Run the API in headless mode (default: False). This will not open a browser window.
|
31
|
+
"""
|
32
|
+
await assert_auth_enabled()
|
33
|
+
|
34
|
+
auth_session_input = await load_parameters(parameters) or {}
|
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
|
+
await execute_run_create_auth_session_cli(
|
43
|
+
id=id,
|
44
|
+
input_data=auth_session_input,
|
45
|
+
check_retries=check_attempts,
|
46
|
+
create_retries=create_attempts,
|
47
|
+
headless=headless,
|
48
|
+
proxy=proxy,
|
49
|
+
timeout=timeout_value,
|
50
|
+
)
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import arguably
|
2
|
+
import pytimeparse # type: ignore
|
3
|
+
|
4
|
+
from intuned_cli.controller.authsession import execute_run_update_auth_session_cli
|
5
|
+
from intuned_cli.utils.auth_session_helpers import assert_auth_enabled
|
6
|
+
from intuned_cli.utils.auth_session_helpers import load_parameters
|
7
|
+
|
8
|
+
|
9
|
+
@arguably.command # type: ignore
|
10
|
+
async def run__authsession__update(
|
11
|
+
id: str,
|
12
|
+
/,
|
13
|
+
*,
|
14
|
+
parameters: str | None = None,
|
15
|
+
check_attempts: int = 1,
|
16
|
+
create_attempts: int = 1,
|
17
|
+
proxy: str | None = None,
|
18
|
+
timeout: str = "10 min",
|
19
|
+
headless: bool = False,
|
20
|
+
):
|
21
|
+
"""Update an existing auth session
|
22
|
+
|
23
|
+
Args:
|
24
|
+
id (str): ID of the auth session to update
|
25
|
+
parameters (str | None, optional): [--parameters]. Parameters for the auth session command. If not provided, it will use the existing parameters.
|
26
|
+
check_attempts (int, optional): [--check-attempts]. Number of attempts to check the auth session validity. Defaults to 1.
|
27
|
+
create_attempts (int, optional): [--create-attempts]. Number of attempts to create a new auth session if it is invalid. Defaults to 1.
|
28
|
+
proxy (str | None, optional): [--proxy]. Proxy URL to use for the auth session command. Defaults to None.
|
29
|
+
timeout (str, optional): [--timeout]. Timeout for the auth session command - milliseconds or pytimeparse-formatted string. Defaults to "10 min".
|
30
|
+
headless (bool, optional): [--headless]. Run the API in headless mode (default: False). This will not open a browser window.
|
31
|
+
"""
|
32
|
+
await assert_auth_enabled()
|
33
|
+
|
34
|
+
auth_session_input = None
|
35
|
+
if parameters:
|
36
|
+
auth_session_input = await load_parameters(parameters)
|
37
|
+
|
38
|
+
timeout_value = pytimeparse.parse(timeout) # type: ignore
|
39
|
+
if timeout_value is None:
|
40
|
+
raise ValueError(
|
41
|
+
f"Invalid timeout format: {timeout}. Please use a valid time format like '10 min' or '600 seconds'."
|
42
|
+
)
|
43
|
+
|
44
|
+
await execute_run_update_auth_session_cli(
|
45
|
+
id=id,
|
46
|
+
input_data=auth_session_input,
|
47
|
+
check_retries=check_attempts,
|
48
|
+
create_retries=create_attempts,
|
49
|
+
headless=headless,
|
50
|
+
proxy=proxy,
|
51
|
+
timeout=timeout_value,
|
52
|
+
)
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import arguably
|
2
|
+
import pytimeparse # type: ignore
|
3
|
+
|
4
|
+
from intuned_cli.controller.authsession import execute_run_validate_auth_session_cli
|
5
|
+
from intuned_cli.utils.auth_session_helpers import assert_auth_enabled
|
6
|
+
|
7
|
+
|
8
|
+
@arguably.command # type: ignore
|
9
|
+
async def run__authsession__validate(
|
10
|
+
id: str,
|
11
|
+
/,
|
12
|
+
*,
|
13
|
+
check_attempts: int = 1,
|
14
|
+
create_attempts: int = 1,
|
15
|
+
proxy: str | None = None,
|
16
|
+
timeout: str = "10 min",
|
17
|
+
no_auto_recreate: bool = False,
|
18
|
+
headless: bool = False,
|
19
|
+
):
|
20
|
+
"""Validate an existing auth session
|
21
|
+
|
22
|
+
Args:
|
23
|
+
id (str): ID of the auth session to validate
|
24
|
+
check_attempts (int, optional): [--check-attempts]. Number of attempts to check the auth session validity. Defaults to 1.
|
25
|
+
create_attempts (int, optional): [--create-attempts]. Number of attempts to create a new auth session if it is invalid. Defaults to 1.
|
26
|
+
proxy (str | None, optional): [--proxy]. Proxy URL to use for the auth session command. Defaults to None.
|
27
|
+
timeout (str, optional): [--timeout]. Timeout for the auth session command - milliseconds or pytimeparse-formatted string. Defaults to "10 min".
|
28
|
+
no_auto_recreate (bool, optional): [--no-auto-recreate]. Disable auto recreation of the auth session if it is invalid. Defaults to False.
|
29
|
+
headless (bool, optional): [--headless]. Run the API in headless mode (default: False). This will not open a browser window.
|
30
|
+
"""
|
31
|
+
await assert_auth_enabled()
|
32
|
+
|
33
|
+
auto_recreate = not no_auto_recreate
|
34
|
+
|
35
|
+
timeout_value = pytimeparse.parse(timeout) # type: ignore
|
36
|
+
if timeout_value is None:
|
37
|
+
raise ValueError(
|
38
|
+
f"Invalid timeout format: {timeout}. Please use a valid time format like '10 min' or '600 seconds'."
|
39
|
+
)
|
40
|
+
|
41
|
+
await execute_run_validate_auth_session_cli(
|
42
|
+
id=id,
|
43
|
+
auto_recreate=auto_recreate,
|
44
|
+
check_retries=check_attempts,
|
45
|
+
create_retries=create_attempts,
|
46
|
+
headless=headless,
|
47
|
+
proxy=proxy,
|
48
|
+
timeout=timeout_value,
|
49
|
+
)
|
@@ -0,0 +1 @@
|
|
1
|
+
from .readme import readme as readme
|