pingera-cli 0.1.14__tar.gz → 0.1.15__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.
- {pingera_cli-0.1.14/pingera_cli.egg-info → pingera_cli-0.1.15}/PKG-INFO +2 -2
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/__init__.py +1 -1
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/commands/checks.py +74 -27
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/commands/on_demand_checks.py +53 -15
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/formatters/__init__.py +2 -1
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/formatters/base_formatter.py +7 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/formatters/multistep_formatter.py +30 -31
- pingera_cli-0.1.15/pingera_cli/formatters/portscan_formatter.py +189 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/formatters/registry.py +2 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/formatters/ssl_formatter.py +77 -27
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/formatters/web_formatter.py +37 -32
- pingera_cli-0.1.15/pingera_cli/main.py +455 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15/pingera_cli.egg-info}/PKG-INFO +2 -2
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli.egg-info/SOURCES.txt +1 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli.egg-info/requires.txt +1 -1
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pyproject.toml +1 -1
- pingera_cli-0.1.14/pingera_cli/main.py +0 -227
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/.gitignore +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/.replit +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/LICENSE +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/README.md +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/assert +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/docs/cli-commands.md +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/docs/example-check.yaml +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/docs/example-synthetic-screenshot.json +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/docs/example-web-check.json +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/__main__.py +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/commands/__init__.py +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/commands/auth.py +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/commands/base.py +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/commands/check_groups.py +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/commands/check_secrets.py +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/commands/execution_groups.py +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/commands/secrets.py +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/formatters/dns_formatter.py +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/formatters/generic_formatter.py +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/formatters/icmp_formatter.py +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/formatters/synthetic_formatter.py +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/utils/__init__.py +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/utils/config.py +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/utils/console.py +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli/utils/file_utils.py +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli.egg-info/dependency_links.txt +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli.egg-info/entry_points.txt +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pingera_cli.egg-info/top_level.txt +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/pwscript.js +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/replit.md +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/run_tests.py +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/setup.cfg +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/setup.py +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/tests/__init__.py +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/tests/conftest.py +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/tests/requirements.txt +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/tests/test_auth.py +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/tests/test_checks.py +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/tests/test_config.py +0 -0
- {pingera_cli-0.1.14 → pingera_cli-0.1.15}/tests/test_on_demand_checks.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pingera-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.15
|
|
4
4
|
Summary: A beautiful Python CLI tool built with typer and rich, distributed via pip and based on Pingera SDK
|
|
5
5
|
Home-page: https://github.com/pingera/pingera-cli
|
|
6
6
|
Author: PingeraCLI Team
|
|
@@ -31,7 +31,7 @@ Description-Content-Type: text/markdown
|
|
|
31
31
|
License-File: LICENSE
|
|
32
32
|
Requires-Dist: typer[all]>=0.9.0
|
|
33
33
|
Requires-Dist: rich>=13.0.0
|
|
34
|
-
Requires-Dist: pingera-sdk>=1.0.
|
|
34
|
+
Requires-Dist: pingera-sdk>=1.0.13
|
|
35
35
|
Requires-Dist: click>=8.0.0
|
|
36
36
|
Provides-Extra: dev
|
|
37
37
|
Requires-Dist: pytest>=6.0; extra == "dev"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Pingera CLI - A beautiful CLI tool for Pingera Platform
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
__version__ = "0.1.
|
|
5
|
+
__version__ = "0.1.15"
|
|
6
6
|
__author__ = "Pingera Team"
|
|
7
7
|
__description__ = "A beautiful Python CLI tool built with typer and rich, distributed via pip and based on Pingera SDK"
|
|
8
8
|
|
|
@@ -14,6 +14,9 @@ from rich.prompt import Confirm
|
|
|
14
14
|
from .base import BaseCommand
|
|
15
15
|
from ..utils.config import get_api_key
|
|
16
16
|
|
|
17
|
+
# Supported check types
|
|
18
|
+
SUPPORTED_CHECK_TYPES = ["web", "api", "tcp", "ssl", "dns", "icmp", "portscan", "synthetic", "multistep"]
|
|
19
|
+
|
|
17
20
|
|
|
18
21
|
class ChecksCommand(BaseCommand):
|
|
19
22
|
"""
|
|
@@ -412,7 +415,7 @@ class ChecksCommand(BaseCommand):
|
|
|
412
415
|
self.display_error(str(e))
|
|
413
416
|
raise typer.Exit(1)
|
|
414
417
|
|
|
415
|
-
def create_check(self, name: str, check_type: str, url: Optional[str] = None, host: Optional[str] = None, port: Optional[int] = None, interval: int = 300, timeout: int = 30, parameters: Optional[str] = None, pw_script_file: Optional[str] = None, from_file: Optional[str] = None):
|
|
418
|
+
def create_check(self, name: str, check_type: str, url: Optional[str] = None, host: Optional[str] = None, port: Optional[int] = None, interval: int = 300, timeout: int = 30, parameters: Optional[str] = None, pw_script_file: Optional[str] = None, from_file: Optional[str] = None, regions: Optional[str] = None):
|
|
416
419
|
"""Create a new monitoring check"""
|
|
417
420
|
try:
|
|
418
421
|
import json
|
|
@@ -525,7 +528,14 @@ class ChecksCommand(BaseCommand):
|
|
|
525
528
|
self.display_error(f"Failed to read Playwright script file: {str(e)}")
|
|
526
529
|
raise typer.Exit(1)
|
|
527
530
|
|
|
528
|
-
#
|
|
531
|
+
# Handle regions parameter - add to params_dict if provided and not in parameters
|
|
532
|
+
if regions is not None and parameters is None:
|
|
533
|
+
# Parse comma-separated regions into a list
|
|
534
|
+
regions_list = [r.strip() for r in regions.split(',') if r.strip()]
|
|
535
|
+
if regions_list:
|
|
536
|
+
params_dict["regions"] = regions_list
|
|
537
|
+
|
|
538
|
+
# Parse parameters JSON if provided (this takes precedence over --regions)
|
|
529
539
|
if parameters is not None:
|
|
530
540
|
try:
|
|
531
541
|
parsed_params = json.loads(parameters)
|
|
@@ -583,7 +593,7 @@ class ChecksCommand(BaseCommand):
|
|
|
583
593
|
self.display_error(f"Failed to create check: {str(e)}")
|
|
584
594
|
raise typer.Exit(1)
|
|
585
595
|
|
|
586
|
-
def update_check(self, check_id: str, name: Optional[str] = None, url: Optional[str] = None, host: Optional[str] = None, port: Optional[int] = None, interval: Optional[int] = None, timeout: Optional[int] = None, active: Optional[bool] = None, parameters: Optional[str] = None, pw_script_file: Optional[str] = None):
|
|
596
|
+
def update_check(self, check_id: str, name: Optional[str] = None, url: Optional[str] = None, host: Optional[str] = None, port: Optional[int] = None, interval: Optional[int] = None, timeout: Optional[int] = None, active: Optional[bool] = None, parameters: Optional[str] = None, pw_script_file: Optional[str] = None, regions: Optional[str] = None):
|
|
587
597
|
"""Update an existing check"""
|
|
588
598
|
try:
|
|
589
599
|
import json
|
|
@@ -629,7 +639,14 @@ class ChecksCommand(BaseCommand):
|
|
|
629
639
|
self.display_error(f"Failed to read Playwright script file: {str(e)}")
|
|
630
640
|
raise typer.Exit(1)
|
|
631
641
|
|
|
632
|
-
#
|
|
642
|
+
# Handle regions parameter - add to params_dict if provided and not in parameters
|
|
643
|
+
if regions is not None and parameters is None:
|
|
644
|
+
# Parse comma-separated regions into a list
|
|
645
|
+
regions_list = [r.strip() for r in regions.split(',') if r.strip()]
|
|
646
|
+
if regions_list:
|
|
647
|
+
params_dict["regions"] = regions_list
|
|
648
|
+
|
|
649
|
+
# Parse parameters JSON if provided (this takes precedence over --regions)
|
|
633
650
|
if parameters is not None:
|
|
634
651
|
try:
|
|
635
652
|
parsed_params = json.loads(parameters)
|
|
@@ -749,7 +766,7 @@ class ChecksCommand(BaseCommand):
|
|
|
749
766
|
# If result_id was specified, we're fetching a single result - display it with full formatting
|
|
750
767
|
if result_id and len(response.results) == 1:
|
|
751
768
|
result = response.results[0]
|
|
752
|
-
|
|
769
|
+
|
|
753
770
|
if self.output_format in ['json', 'yaml']:
|
|
754
771
|
result_dict = {
|
|
755
772
|
"id": str(result.id) if hasattr(result, 'id') and result.id else None,
|
|
@@ -901,10 +918,8 @@ class ChecksCommand(BaseCommand):
|
|
|
901
918
|
|
|
902
919
|
# Provide helpful hints based on context
|
|
903
920
|
hints = []
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
else:
|
|
907
|
-
hints.append("Use 'pngr checks results --result-id <result-id>' for detailed result info")
|
|
921
|
+
hints.append("Use 'pngr checks result <result-id>' for detailed result info")
|
|
922
|
+
if not check_id:
|
|
908
923
|
hints.append("Use 'pngr checks list' to see all available checks and their IDs")
|
|
909
924
|
hints.append("Filter results: --type <type>, --status <status>, --region <region>")
|
|
910
925
|
|
|
@@ -935,16 +950,19 @@ class ChecksCommand(BaseCommand):
|
|
|
935
950
|
self.display_error(f"Failed to get result details: {str(e)}")
|
|
936
951
|
raise typer.Exit(1)
|
|
937
952
|
|
|
938
|
-
def get_check_result_detailed(self,
|
|
939
|
-
"""Get detailed information for a specific check result using
|
|
953
|
+
def get_check_result_detailed(self, result_id: str, verbose: bool = False):
|
|
954
|
+
"""Get detailed information for a specific check result using result_id"""
|
|
940
955
|
try:
|
|
941
|
-
|
|
956
|
+
unified_api = self.get_unified_results_client()
|
|
942
957
|
|
|
943
|
-
# Use the
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
958
|
+
# Use the unified results API with result_id filter
|
|
959
|
+
response = unified_api.v1_checks_all_results_get(result_id=result_id)
|
|
960
|
+
|
|
961
|
+
if not hasattr(response, 'results') or not response.results or len(response.results) == 0:
|
|
962
|
+
self.display_error(f"Result {result_id} not found")
|
|
963
|
+
raise typer.Exit(1)
|
|
964
|
+
|
|
965
|
+
result = response.results[0]
|
|
948
966
|
|
|
949
967
|
if self.output_format in ['json', 'yaml']:
|
|
950
968
|
# Full result data for JSON/YAML
|
|
@@ -979,7 +997,7 @@ class ChecksCommand(BaseCommand):
|
|
|
979
997
|
response_time_display = f"{result.response_time}ms"
|
|
980
998
|
else:
|
|
981
999
|
response_time_display = 'N/A'
|
|
982
|
-
|
|
1000
|
+
|
|
983
1001
|
basic_info = f"""[bold cyan]Basic Information:[/bold cyan]
|
|
984
1002
|
• Result ID: [white]{result.id}[/white]
|
|
985
1003
|
• Check ID: [white]{result.check_id}[/white]
|
|
@@ -1058,6 +1076,7 @@ class ChecksCommand(BaseCommand):
|
|
|
1058
1076
|
region_dict = {
|
|
1059
1077
|
"id": str(region.id) if hasattr(region, 'id') and region.id else None,
|
|
1060
1078
|
"display_name": region.display_name if hasattr(region, 'display_name') and region.display_name else None,
|
|
1079
|
+
"aliases": region.aliases if hasattr(region, 'aliases') and region.aliases else None,
|
|
1061
1080
|
"available_check_types": region.available_check_types if hasattr(region, 'available_check_types') and region.available_check_types else None
|
|
1062
1081
|
}
|
|
1063
1082
|
regions_data.append(region_dict)
|
|
@@ -1073,6 +1092,7 @@ class ChecksCommand(BaseCommand):
|
|
|
1073
1092
|
table = Table(title=table_title)
|
|
1074
1093
|
table.add_column("Region ID", style="cyan", min_width=15)
|
|
1075
1094
|
table.add_column("Display Name", style="green", min_width=25)
|
|
1095
|
+
table.add_column("Aliases", style="yellow", min_width=20)
|
|
1076
1096
|
table.add_column("Available Check Types", style="white")
|
|
1077
1097
|
|
|
1078
1098
|
for region in response.regions:
|
|
@@ -1080,6 +1100,14 @@ class ChecksCommand(BaseCommand):
|
|
|
1080
1100
|
region_id = str(region.id) if hasattr(region, 'id') and region.id else "-"
|
|
1081
1101
|
display_name = region.display_name if hasattr(region, 'display_name') and region.display_name else "-"
|
|
1082
1102
|
|
|
1103
|
+
# Handle aliases
|
|
1104
|
+
aliases_display = "-"
|
|
1105
|
+
if hasattr(region, 'aliases') and region.aliases:
|
|
1106
|
+
if isinstance(region.aliases, list):
|
|
1107
|
+
aliases_display = ", ".join(region.aliases)
|
|
1108
|
+
else:
|
|
1109
|
+
aliases_display = str(region.aliases)
|
|
1110
|
+
|
|
1083
1111
|
# Handle available check types
|
|
1084
1112
|
available_types = "-"
|
|
1085
1113
|
if hasattr(region, 'available_check_types') and region.available_check_types:
|
|
@@ -1091,6 +1119,7 @@ class ChecksCommand(BaseCommand):
|
|
|
1091
1119
|
table.add_row(
|
|
1092
1120
|
region_id,
|
|
1093
1121
|
display_name,
|
|
1122
|
+
aliases_display,
|
|
1094
1123
|
available_types
|
|
1095
1124
|
)
|
|
1096
1125
|
|
|
@@ -1169,15 +1198,15 @@ def list_checks(
|
|
|
1169
1198
|
):
|
|
1170
1199
|
"""List monitoring checks with advanced filtering options"""
|
|
1171
1200
|
from ..utils.config import get_output_format
|
|
1172
|
-
|
|
1201
|
+
|
|
1173
1202
|
# Validate name length
|
|
1174
1203
|
if name and len(name) > 100:
|
|
1175
1204
|
typer.echo("Error: Name filter cannot exceed 100 characters", err=True)
|
|
1176
1205
|
raise typer.Exit(1)
|
|
1177
1206
|
|
|
1178
1207
|
# Validate check type
|
|
1179
|
-
if check_type and check_type not in
|
|
1180
|
-
typer.echo("Error: Invalid check type. Must be one of:
|
|
1208
|
+
if check_type and check_type not in SUPPORTED_CHECK_TYPES:
|
|
1209
|
+
typer.echo(f"Error: Invalid check type '{check_type}'. Must be one of: {', '.join(SUPPORTED_CHECK_TYPES)}", err=True)
|
|
1181
1210
|
raise typer.Exit(1)
|
|
1182
1211
|
|
|
1183
1212
|
# Validate status values if provided
|
|
@@ -1214,7 +1243,8 @@ def create_check(
|
|
|
1214
1243
|
timeout: int = typer.Option(30, "--timeout", help="Timeout in seconds"),
|
|
1215
1244
|
parameters: Optional[str] = typer.Option(None, "--parameters", help="JSON string with check parameters (e.g., '{\"regions\": [\"US\", \"EU\"]}')"),
|
|
1216
1245
|
pw_script_file: Optional[str] = typer.Option(None, "--pw-script-file", help="Path to file containing Playwright script for synthetic/multistep checks"),
|
|
1217
|
-
from_file: Optional[str] = typer.Option(None, "--from-file", "-f", help="Path to JSON or YAML file containing check configuration")
|
|
1246
|
+
from_file: Optional[str] = typer.Option(None, "--from-file", "-f", help="Path to JSON or YAML file containing check configuration"),
|
|
1247
|
+
regions: Optional[str] = typer.Option(None, "--regions", help="Comma-separated list of regions (e.g., 'ru-central1,eu-west1')"),
|
|
1218
1248
|
):
|
|
1219
1249
|
"""Create a new monitoring check. Can be created from command line options or from a JSON/YAML file.
|
|
1220
1250
|
|
|
@@ -1236,8 +1266,13 @@ def create_check(
|
|
|
1236
1266
|
typer.echo("Error: --name is required when not using --from-file", err=True)
|
|
1237
1267
|
raise typer.Exit(1)
|
|
1238
1268
|
|
|
1269
|
+
# Validate check type
|
|
1270
|
+
if check_type not in SUPPORTED_CHECK_TYPES:
|
|
1271
|
+
typer.echo(f"Error: Invalid check type '{check_type}'. Must be one of: {', '.join(SUPPORTED_CHECK_TYPES)}", err=True)
|
|
1272
|
+
raise typer.Exit(1)
|
|
1273
|
+
|
|
1239
1274
|
checks_cmd = ChecksCommand(get_output_format())
|
|
1240
|
-
checks_cmd.create_check(name, check_type, url, host, port, interval, timeout, parameters, pw_script_file, from_file)
|
|
1275
|
+
checks_cmd.create_check(name, check_type, url, host, port, interval, timeout, parameters, pw_script_file, from_file, regions)
|
|
1241
1276
|
|
|
1242
1277
|
|
|
1243
1278
|
@app.command("update")
|
|
@@ -1251,12 +1286,13 @@ def update_check(
|
|
|
1251
1286
|
timeout: Optional[int] = typer.Option(None, "--timeout", help="New timeout in seconds"),
|
|
1252
1287
|
active: bool = typer.Option(None, "--active/--inactive", help="Enable or disable the check"),
|
|
1253
1288
|
parameters: Optional[str] = typer.Option(None, "--parameters", help="JSON string with check parameters (e.g., '{\"pw_script\": \"...\", \"regions\": [\"US\", \"EU\"]}')"),
|
|
1254
|
-
pw_script_file: Optional[str] = typer.Option(None, "--pw-script-file", help="Path to file containing Playwright script for synthetic/multistep checks")
|
|
1289
|
+
pw_script_file: Optional[str] = typer.Option(None, "--pw-script-file", help="Path to file containing Playwright script for synthetic/multistep checks"),
|
|
1290
|
+
regions: Optional[str] = typer.Option(None, "--regions", help="Comma-separated list of regions (e.g., 'ru-central1,eu-west1')"),
|
|
1255
1291
|
):
|
|
1256
1292
|
"""Update an existing check. Use --parameters to provide complex parameters like Playwright scripts, regions, etc."""
|
|
1257
1293
|
from ..utils.config import get_output_format
|
|
1258
1294
|
checks_cmd = ChecksCommand(get_output_format())
|
|
1259
|
-
checks_cmd.update_check(check_id, name, url, host, port, interval, timeout, active, parameters, pw_script_file)
|
|
1295
|
+
checks_cmd.update_check(check_id, name, url, host, port, interval, timeout, active, parameters, pw_script_file, regions)
|
|
1260
1296
|
|
|
1261
1297
|
|
|
1262
1298
|
@app.command("delete")
|
|
@@ -1284,20 +1320,25 @@ def get_results(
|
|
|
1284
1320
|
):
|
|
1285
1321
|
"""Get check results with advanced filtering. If no check_id is provided, returns unified results across all checks. Use --result-id to fetch a specific result."""
|
|
1286
1322
|
from ..utils.config import get_output_format
|
|
1323
|
+
|
|
1324
|
+
# Validate check type
|
|
1325
|
+
if check_type and check_type not in SUPPORTED_CHECK_TYPES:
|
|
1326
|
+
typer.echo(f"Error: Invalid check type '{check_type}'. Must be one of: {', '.join(SUPPORTED_CHECK_TYPES)}", err=True)
|
|
1327
|
+
raise typer.Exit(1)
|
|
1328
|
+
|
|
1287
1329
|
checks_cmd = ChecksCommand(get_output_format())
|
|
1288
1330
|
checks_cmd.get_check_results(check_id, from_date, to_date, page, page_size, status, check_type, region, result_id)
|
|
1289
1331
|
|
|
1290
1332
|
|
|
1291
1333
|
@app.command("result")
|
|
1292
1334
|
def get_result(
|
|
1293
|
-
check_id: str = typer.Argument(..., help="Check ID"),
|
|
1294
1335
|
result_id: str = typer.Argument(..., help="Result ID to retrieve detailed information for"),
|
|
1295
1336
|
verbose: bool = typer.Option(False, "--verbose", "-v", help="Show full detailed information including network requests"),
|
|
1296
1337
|
):
|
|
1297
1338
|
"""Get detailed information for a specific check result"""
|
|
1298
1339
|
from ..utils.config import get_output_format
|
|
1299
1340
|
checks_cmd = ChecksCommand(get_output_format())
|
|
1300
|
-
checks_cmd.get_check_result_detailed(
|
|
1341
|
+
checks_cmd.get_check_result_detailed(result_id, verbose)
|
|
1301
1342
|
|
|
1302
1343
|
|
|
1303
1344
|
@app.command("list-regions")
|
|
@@ -1306,6 +1347,12 @@ def list_regions(
|
|
|
1306
1347
|
):
|
|
1307
1348
|
"""List available regions for monitoring checks"""
|
|
1308
1349
|
from ..utils.config import get_output_format
|
|
1350
|
+
|
|
1351
|
+
# Validate check type
|
|
1352
|
+
if check_type and check_type not in SUPPORTED_CHECK_TYPES:
|
|
1353
|
+
typer.echo(f"Error: Invalid check type '{check_type}'. Must be one of: {', '.join(SUPPORTED_CHECK_TYPES)}", err=True)
|
|
1354
|
+
raise typer.Exit(1)
|
|
1355
|
+
|
|
1309
1356
|
checks_cmd = ChecksCommand(get_output_format())
|
|
1310
1357
|
checks_cmd.list_regions(check_type)
|
|
1311
1358
|
|
|
@@ -13,6 +13,9 @@ from rich.panel import Panel
|
|
|
13
13
|
from .base import BaseCommand
|
|
14
14
|
from ..utils.config import get_api_key
|
|
15
15
|
|
|
16
|
+
# Supported check types for on-demand execution
|
|
17
|
+
SUPPORTED_CHECK_TYPES = ["web", "api", "tcp", "ssl", "dns", "icmp", "portscan", "synthetic", "multistep"]
|
|
18
|
+
|
|
16
19
|
|
|
17
20
|
class OnDemandChecksCommand(BaseCommand):
|
|
18
21
|
"""
|
|
@@ -64,7 +67,7 @@ class OnDemandChecksCommand(BaseCommand):
|
|
|
64
67
|
self.display_error(f"Failed to initialize client: {str(e)}")
|
|
65
68
|
raise typer.Exit(1)
|
|
66
69
|
|
|
67
|
-
def execute_custom_check(self, url: Optional[str] = None, check_type: str = "web", host: Optional[str] = None, port: Optional[int] = None, timeout: int =
|
|
70
|
+
def execute_custom_check(self, url: Optional[str] = None, check_type: str = "web", host: Optional[str] = None, port: Optional[int] = None, timeout: Optional[int] = None, name: str = "On-demand check", regions: Optional[str] = None, parameters: Optional[str] = None, pw_script_file: Optional[str] = None, from_file: Optional[str] = None, wait_for_result: bool = True, ports: Optional[str] = None):
|
|
68
71
|
"""Execute custom on-demand check"""
|
|
69
72
|
try:
|
|
70
73
|
import json
|
|
@@ -86,10 +89,15 @@ class OnDemandChecksCommand(BaseCommand):
|
|
|
86
89
|
# Command line options take precedence over file data
|
|
87
90
|
check_data = {
|
|
88
91
|
"name": filtered_file_data.get("name", name),
|
|
89
|
-
"type": filtered_file_data.get("type", check_type)
|
|
90
|
-
"timeout": filtered_file_data.get("timeout", timeout)
|
|
92
|
+
"type": filtered_file_data.get("type", check_type)
|
|
91
93
|
}
|
|
92
94
|
|
|
95
|
+
# Handle timeout - only set if explicitly provided or in file
|
|
96
|
+
if timeout is not None:
|
|
97
|
+
check_data["timeout"] = timeout
|
|
98
|
+
elif "timeout" in filtered_file_data:
|
|
99
|
+
check_data["timeout"] = filtered_file_data["timeout"]
|
|
100
|
+
|
|
93
101
|
# Override with command line values if provided
|
|
94
102
|
if name != "On-demand check": # Only override if name was explicitly provided
|
|
95
103
|
check_data["name"] = name
|
|
@@ -142,9 +150,12 @@ class OnDemandChecksCommand(BaseCommand):
|
|
|
142
150
|
# Build check data normally
|
|
143
151
|
check_data = {
|
|
144
152
|
"name": name,
|
|
145
|
-
"type": check_type
|
|
146
|
-
"timeout": timeout
|
|
153
|
+
"type": check_type
|
|
147
154
|
}
|
|
155
|
+
|
|
156
|
+
# Only set timeout if explicitly provided by user
|
|
157
|
+
if timeout is not None:
|
|
158
|
+
check_data["timeout"] = timeout
|
|
148
159
|
|
|
149
160
|
# Add URL if provided (required for web, api, ssl checks)
|
|
150
161
|
if url is not None:
|
|
@@ -178,7 +189,18 @@ class OnDemandChecksCommand(BaseCommand):
|
|
|
178
189
|
self.display_error(f"Failed to read Playwright script file: {str(e)}")
|
|
179
190
|
raise typer.Exit(1)
|
|
180
191
|
|
|
181
|
-
#
|
|
192
|
+
# Handle regions parameter - add to params_dict if provided and not in parameters
|
|
193
|
+
if regions is not None and parameters is None:
|
|
194
|
+
# Parse comma-separated regions into a list
|
|
195
|
+
regions_list = [r.strip() for r in regions.split(',') if r.strip()]
|
|
196
|
+
if regions_list:
|
|
197
|
+
params_dict["regions"] = regions_list
|
|
198
|
+
|
|
199
|
+
# Handle ports parameter - add to params_dict if provided and not in parameters
|
|
200
|
+
if ports is not None and parameters is None:
|
|
201
|
+
params_dict["ports"] = ports
|
|
202
|
+
|
|
203
|
+
# Parse parameters JSON if provided (this takes precedence over --regions and --ports)
|
|
182
204
|
if parameters is not None:
|
|
183
205
|
try:
|
|
184
206
|
parsed_params = json.loads(parameters)
|
|
@@ -195,11 +217,17 @@ class OnDemandChecksCommand(BaseCommand):
|
|
|
195
217
|
|
|
196
218
|
# Validation based on check type - use the actual type from check_data
|
|
197
219
|
actual_check_type = check_data.get("type", check_type)
|
|
220
|
+
|
|
221
|
+
# Validate check type is supported
|
|
222
|
+
if actual_check_type not in SUPPORTED_CHECK_TYPES:
|
|
223
|
+
self.display_error(f"Invalid check type: {actual_check_type}. Supported types: {', '.join(SUPPORTED_CHECK_TYPES)}")
|
|
224
|
+
raise typer.Exit(1)
|
|
225
|
+
|
|
198
226
|
if actual_check_type in ['web', 'api'] and not url:
|
|
199
227
|
self.display_error(f"URL is required for {actual_check_type} checks")
|
|
200
228
|
raise typer.Exit(1)
|
|
201
229
|
|
|
202
|
-
if actual_check_type in ['tcp'] and not host:
|
|
230
|
+
if actual_check_type in ['tcp', 'portscan', 'dns', 'icmp'] and not host:
|
|
203
231
|
self.display_error(f"Host is required for {actual_check_type} checks")
|
|
204
232
|
raise typer.Exit(1)
|
|
205
233
|
|
|
@@ -702,8 +730,13 @@ class OnDemandChecksCommand(BaseCommand):
|
|
|
702
730
|
metadata = detailed_result.check_metadata
|
|
703
731
|
|
|
704
732
|
if isinstance(metadata, dict):
|
|
733
|
+
# Add result_id to metadata for formatters to use in truncation notice
|
|
734
|
+
metadata_with_id = metadata.copy()
|
|
735
|
+
if hasattr(detailed_result, 'id'):
|
|
736
|
+
metadata_with_id['result_id'] = detailed_result.id
|
|
737
|
+
|
|
705
738
|
registry = FormatterRegistry(verbose=self.verbose)
|
|
706
|
-
metadata_info = registry.format_metadata(
|
|
739
|
+
metadata_info = registry.format_metadata(metadata_with_id)
|
|
707
740
|
|
|
708
741
|
# Combine all sections
|
|
709
742
|
full_info = basic_info
|
|
@@ -958,11 +991,13 @@ def get_verbose_mode():
|
|
|
958
991
|
@run_app.command("custom")
|
|
959
992
|
def run_custom_check(
|
|
960
993
|
url: Optional[str] = typer.Option(None, "--url", "-u", help="URL to monitor (required for web, api, ssl checks)"),
|
|
961
|
-
check_type: str = typer.Option("web", "--type", "-t", help="Check type
|
|
962
|
-
host: Optional[str] = typer.Option(None, "--host", help="Hostname/IP for TCP/SSL checks (max 255 characters)"),
|
|
963
|
-
port: Optional[int] = typer.Option(None, "--port", help="Port number for TCP checks (1-65535)"),
|
|
964
|
-
|
|
994
|
+
check_type: str = typer.Option("web", "--type", "-t", help=f"Check type: {', '.join(SUPPORTED_CHECK_TYPES)}"),
|
|
995
|
+
host: Optional[str] = typer.Option(None, "--host", help="Hostname/IP for TCP/SSL/portscan/DNS/ICMP checks (max 255 characters)"),
|
|
996
|
+
port: Optional[int] = typer.Option(None, "--port", "-p", help="Port number for TCP/SSL checks (1-65535)"),
|
|
997
|
+
ports: Optional[str] = typer.Option(None, "--ports", help="Ports to scan for portscan checks (e.g., '80,443' or '1-1024'). Overridden by --parameters if both are specified."),
|
|
998
|
+
timeout: Optional[int] = typer.Option(None, "--timeout", help="Timeout in seconds (optional - backend will use defaults if not specified)"),
|
|
965
999
|
name: str = typer.Option("On-demand check", "--name", "-n", help="Check name"),
|
|
1000
|
+
regions: Optional[str] = typer.Option(None, "--regions", "-r", help="Comma-separated list of regions (e.g., 'ru-central1,eu-west1'). Overridden by --parameters if both are specified."),
|
|
966
1001
|
parameters: Optional[str] = typer.Option(None, "--parameters", help="JSON string with check parameters (e.g., '{\"regions\": [\"US\", \"EU\"]}')"),
|
|
967
1002
|
pw_script_file: Optional[str] = typer.Option(None, "--pw-script-file", help="Path to file containing Playwright script for synthetic/multistep checks"),
|
|
968
1003
|
from_file: Optional[str] = typer.Option(None, "--from-file", "-f", help="Path to JSON or YAML file containing check configuration"),
|
|
@@ -980,10 +1015,13 @@ def run_custom_check(
|
|
|
980
1015
|
Parameters vary by check type:
|
|
981
1016
|
- web/api: --url required
|
|
982
1017
|
- tcp: --host required, --port optional
|
|
983
|
-
- ssl: --url or --host required
|
|
984
|
-
-
|
|
1018
|
+
- ssl: --url or --host required, --port optional
|
|
1019
|
+
- portscan: --host required, --ports optional
|
|
1020
|
+
- synthetic/multistep: --pw-script-file or --parameters with pw_script required
|
|
1021
|
+
|
|
1022
|
+
Timeout is optional - if not specified, backend will use appropriate defaults for each check type."""
|
|
985
1023
|
on_demand_cmd = OnDemandChecksCommand(get_output_format(), verbose=get_verbose_mode())
|
|
986
|
-
on_demand_cmd.execute_custom_check(url, check_type, host, port, timeout, name, parameters, pw_script_file, from_file, not no_wait)
|
|
1024
|
+
on_demand_cmd.execute_custom_check(url, check_type, host, port, timeout, name, regions, parameters, pw_script_file, from_file, not no_wait, ports)
|
|
987
1025
|
|
|
988
1026
|
|
|
989
1027
|
@run_app.command("existing")
|
|
@@ -9,7 +9,8 @@ from .multistep_formatter import MultistepFormatter
|
|
|
9
9
|
from .web_formatter import WebFormatter
|
|
10
10
|
from .icmp_formatter import ICMPFormatter
|
|
11
11
|
from .dns_formatter import DNSFormatter
|
|
12
|
+
from .portscan_formatter import PortscanFormatter
|
|
12
13
|
from .generic_formatter import GenericFormatter
|
|
13
14
|
from .registry import FormatterRegistry
|
|
14
15
|
|
|
15
|
-
__all__ = ['SSLFormatter', 'SyntheticFormatter', 'MultistepFormatter', 'WebFormatter', 'ICMPFormatter', 'DNSFormatter', 'GenericFormatter', 'FormatterRegistry']
|
|
16
|
+
__all__ = ['SSLFormatter', 'SyntheticFormatter', 'MultistepFormatter', 'WebFormatter', 'ICMPFormatter', 'DNSFormatter', 'PortscanFormatter', 'GenericFormatter', 'FormatterRegistry']
|
|
@@ -43,3 +43,10 @@ class BaseFormatter(ABC):
|
|
|
43
43
|
def _format_duration(self, duration_ms: float) -> str:
|
|
44
44
|
"""Format duration in milliseconds"""
|
|
45
45
|
return f"{duration_ms:.0f}ms" if duration_ms > 0 else "0ms"
|
|
46
|
+
|
|
47
|
+
def _get_truncation_notice(self, result_id: str = None) -> str:
|
|
48
|
+
"""Get truncation notice with result_id if available"""
|
|
49
|
+
if result_id:
|
|
50
|
+
return f"\n[dim]💡 Some details truncated. Use --verbose flag or view full results at:[/dim]\n[dim] https://app.pingera.ru/checks/jobs/{result_id}[/dim]\n[dim] pngr checks result {result_id} --verbose[/dim]"
|
|
51
|
+
else:
|
|
52
|
+
return "\n[dim]💡 Some details truncated. Use --verbose flag for full details.[/dim]"
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
"""
|
|
3
2
|
Multistep check result formatter
|
|
4
3
|
"""
|
|
@@ -9,103 +8,103 @@ from .base_formatter import BaseFormatter
|
|
|
9
8
|
|
|
10
9
|
class MultistepFormatter(BaseFormatter):
|
|
11
10
|
"""Formatter for multistep check results"""
|
|
12
|
-
|
|
11
|
+
|
|
13
12
|
def can_format(self, metadata: Dict[str, Any]) -> bool:
|
|
14
13
|
"""Check if this is multistep metadata"""
|
|
15
14
|
return 'test_results' in metadata and 'test_summary' in metadata
|
|
16
|
-
|
|
15
|
+
|
|
17
16
|
def format(self, metadata: Dict[str, Any]) -> str:
|
|
18
17
|
"""Format multistep check metadata"""
|
|
19
18
|
info = "\n[bold cyan]Multistep Check Results:[/bold cyan]"
|
|
20
|
-
|
|
19
|
+
|
|
21
20
|
# Execution time
|
|
22
21
|
if 'execution_time' in metadata:
|
|
23
22
|
info += f"\n• Total Execution Time: [yellow]{metadata['execution_time']}ms[/yellow]"
|
|
24
|
-
|
|
23
|
+
|
|
25
24
|
# Test Summary
|
|
26
25
|
if 'test_summary' in metadata:
|
|
27
26
|
info += self._format_test_summary(metadata['test_summary'])
|
|
28
|
-
|
|
27
|
+
|
|
29
28
|
# Test Results
|
|
30
29
|
if 'test_results' in metadata and metadata['test_results']:
|
|
31
30
|
info += self._format_test_results(metadata['test_results'])
|
|
32
|
-
|
|
31
|
+
|
|
33
32
|
# Location info
|
|
34
33
|
if 'region' in metadata:
|
|
35
34
|
info += f"\n• Region: [white]{metadata['region']}[/white]"
|
|
36
35
|
if 'provider' in metadata:
|
|
37
36
|
info += f"\n• Provider: [white]{metadata['provider']}[/white]"
|
|
38
|
-
|
|
37
|
+
|
|
39
38
|
# Logs
|
|
40
39
|
if 'logs' in metadata and metadata['logs']:
|
|
41
40
|
info += self._format_logs(metadata['logs'])
|
|
42
|
-
|
|
41
|
+
|
|
43
42
|
return info
|
|
44
|
-
|
|
43
|
+
|
|
45
44
|
def _format_test_summary(self, summary: Dict[str, Any]) -> str:
|
|
46
45
|
"""Format test summary"""
|
|
47
46
|
total = summary.get('total', 0)
|
|
48
47
|
passed = summary.get('passed', 0)
|
|
49
48
|
failed = summary.get('failed', 0)
|
|
50
49
|
duration = summary.get('duration', 0)
|
|
51
|
-
|
|
50
|
+
|
|
52
51
|
info = f"\n\n[bold cyan]Test Summary:[/bold cyan]"
|
|
53
52
|
info += f"\n• Tests: [green]{passed} passed[/green], [red]{failed} failed[/red], [white]{total} total[/white]"
|
|
54
53
|
info += f"\n• Duration: [yellow]{duration}ms[/yellow]"
|
|
55
|
-
|
|
54
|
+
|
|
56
55
|
return info
|
|
57
|
-
|
|
56
|
+
|
|
58
57
|
def _format_test_results(self, test_results: List[Dict[str, Any]]) -> str:
|
|
59
58
|
"""Format test results"""
|
|
60
59
|
info = "\n\n[bold cyan]Test Results:[/bold cyan]"
|
|
61
|
-
|
|
60
|
+
|
|
62
61
|
for i, test in enumerate(test_results, 1):
|
|
63
62
|
status_color = "green" if test.get('status') == 'passed' else "red"
|
|
64
63
|
status_icon = "✅" if test.get('status') == 'passed' else "❌"
|
|
65
64
|
test_name = test.get('name', f'Test {i}')
|
|
66
65
|
duration = test.get('duration', 0)
|
|
67
|
-
|
|
66
|
+
|
|
68
67
|
info += f"\n• {test_name}: [{status_color}]{status_icon} {test.get('status', 'unknown')}[/{status_color}]"
|
|
69
68
|
info += f" ([yellow]{duration}ms[/yellow])"
|
|
70
|
-
|
|
69
|
+
|
|
71
70
|
# Soft assertion errors
|
|
72
71
|
if test.get('softAssertionErrors', 0) > 0:
|
|
73
72
|
info += f" [yellow]⚠️ {test['softAssertionErrors']} soft assertion errors[/yellow]"
|
|
74
|
-
|
|
73
|
+
|
|
75
74
|
# Error details
|
|
76
75
|
if test.get('error'):
|
|
77
76
|
error_text = self._truncate_text(test['error'], 80) if not self.verbose else test['error']
|
|
78
77
|
info += f"\n [red]Error: {error_text}[/red]"
|
|
79
|
-
|
|
78
|
+
|
|
80
79
|
# Steps
|
|
81
80
|
if 'steps' in test and test['steps']:
|
|
82
81
|
info += self._format_test_steps(test['steps'])
|
|
83
|
-
|
|
82
|
+
|
|
84
83
|
return info
|
|
85
|
-
|
|
84
|
+
|
|
86
85
|
def _format_test_steps(self, steps: List[Dict[str, Any]]) -> str:
|
|
87
86
|
"""Format test steps"""
|
|
88
87
|
info = f"\n [bold dim]Steps:[/bold dim]"
|
|
89
|
-
|
|
88
|
+
|
|
90
89
|
for i, step in enumerate(steps, 1):
|
|
91
90
|
status_color = "green" if step.get('status') == 'passed' else "red"
|
|
92
91
|
status_icon = "✓" if step.get('status') == 'passed' else "✗"
|
|
93
92
|
step_name = step.get('name', f'Step {i}')
|
|
94
93
|
duration = step.get('duration', 0)
|
|
95
|
-
|
|
94
|
+
|
|
96
95
|
info += f"\n {i}. {step_name}: [{status_color}]{status_icon}[/{status_color}] ([dim]{duration}ms[/dim])"
|
|
97
|
-
|
|
96
|
+
|
|
98
97
|
# Step error
|
|
99
98
|
if step.get('error') and (self.verbose or step.get('status') == 'failed'):
|
|
100
99
|
error_text = self._truncate_text(step['error'], 60) if not self.verbose else step['error']
|
|
101
100
|
info += f"\n [red]Error: {error_text}[/red]"
|
|
102
|
-
|
|
101
|
+
|
|
103
102
|
return info
|
|
104
|
-
|
|
103
|
+
|
|
105
104
|
def _format_logs(self, logs: List[Dict[str, Any]]) -> str:
|
|
106
105
|
"""Format execution logs"""
|
|
107
106
|
info = "\n\n[bold cyan]Execution Logs:[/bold cyan]"
|
|
108
|
-
|
|
107
|
+
|
|
109
108
|
if not self.verbose:
|
|
110
109
|
info += f"\n• [dim]Found {len(logs)} log entries (use --verbose to see all)[/dim]"
|
|
111
110
|
# Show only first few logs in non-verbose mode
|
|
@@ -113,7 +112,7 @@ class MultistepFormatter(BaseFormatter):
|
|
|
113
112
|
level = log.get('level', 'log')
|
|
114
113
|
message = self._truncate_text(log.get('message', ''), 60)
|
|
115
114
|
timestamp = log.get('timestamp', '')
|
|
116
|
-
|
|
115
|
+
|
|
117
116
|
level_color = self._get_log_level_color(level)
|
|
118
117
|
info += f"\n• [{level_color}]{level.upper()}[/{level_color}]: [dim]{message}[/dim]"
|
|
119
118
|
else:
|
|
@@ -122,12 +121,12 @@ class MultistepFormatter(BaseFormatter):
|
|
|
122
121
|
level = log.get('level', 'log')
|
|
123
122
|
message = log.get('message', '')
|
|
124
123
|
timestamp = log.get('timestamp', '')
|
|
125
|
-
|
|
124
|
+
|
|
126
125
|
level_color = self._get_log_level_color(level)
|
|
127
126
|
info += f"\n• [{level_color}]{level.upper()}[/{level_color}] [{timestamp}]: {message}"
|
|
128
|
-
|
|
127
|
+
|
|
129
128
|
return info
|
|
130
|
-
|
|
129
|
+
|
|
131
130
|
def _get_log_level_color(self, level: str) -> str:
|
|
132
131
|
"""Get color for log level"""
|
|
133
132
|
colors = {
|
|
@@ -138,4 +137,4 @@ class MultistepFormatter(BaseFormatter):
|
|
|
138
137
|
'log': 'white',
|
|
139
138
|
'debug': 'dim'
|
|
140
139
|
}
|
|
141
|
-
return colors.get(level.lower(), 'white')
|
|
140
|
+
return colors.get(level.lower(), 'white')
|