pingera-cli 0.1.1__tar.gz → 0.1.2__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.1/pingera_cli.egg-info → pingera_cli-0.1.2}/PKG-INFO +1 -1
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pingera_cli/__init__.py +1 -1
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pingera_cli/commands/auth.py +51 -11
- {pingera_cli-0.1.1 → pingera_cli-0.1.2/pingera_cli.egg-info}/PKG-INFO +1 -1
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/.gitignore +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/.replit +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/LICENSE +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/README.md +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/assert +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/docs/cli-commands.md +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pingera_cli/__main__.py +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pingera_cli/commands/__init__.py +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pingera_cli/commands/base.py +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pingera_cli/commands/checks.py +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pingera_cli/commands/on_demand_checks.py +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pingera_cli/formatters/__init__.py +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pingera_cli/formatters/base_formatter.py +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pingera_cli/formatters/generic_formatter.py +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pingera_cli/formatters/multistep_formatter.py +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pingera_cli/formatters/registry.py +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pingera_cli/formatters/ssl_formatter.py +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pingera_cli/formatters/synthetic_formatter.py +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pingera_cli/formatters/web_formatter.py +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pingera_cli/main.py +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pingera_cli/utils/__init__.py +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pingera_cli/utils/config.py +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pingera_cli/utils/console.py +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pingera_cli.egg-info/SOURCES.txt +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pingera_cli.egg-info/dependency_links.txt +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pingera_cli.egg-info/entry_points.txt +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pingera_cli.egg-info/requires.txt +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pingera_cli.egg-info/top_level.txt +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/pyproject.toml +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/replit.md +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/run_tests.py +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/setup.cfg +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/setup.py +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/tests/__init__.py +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/tests/conftest.py +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/tests/requirements.txt +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/tests/test_auth.py +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/tests/test_checks.py +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/tests/test_config.py +0 -0
- {pingera_cli-0.1.1 → pingera_cli-0.1.2}/tests/test_on_demand_checks.py +0 -0
|
@@ -65,8 +65,12 @@ class AuthCommand(BaseCommand):
|
|
|
65
65
|
# Test the API key by making a simple request
|
|
66
66
|
self.console.print("🔍 Validating API key...")
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
validation_status = self._validate_api_key(api_key.strip())
|
|
69
|
+
self.console.print(f"API Key Status: {validation_status}")
|
|
70
|
+
|
|
71
|
+
if "[red]❌ Invalid or expired[/red]" in validation_status:
|
|
72
|
+
self.console.print("[red]Please check your API key and try again.[/red]")
|
|
73
|
+
raise typer.Exit(1)
|
|
70
74
|
|
|
71
75
|
# Save API key to config
|
|
72
76
|
if set_api_key(api_key.strip()):
|
|
@@ -114,15 +118,9 @@ Status: [green]Active[/green]
|
|
|
114
118
|
[dim]Note: Environment variable takes precedence over config file.[/dim]
|
|
115
119
|
"""
|
|
116
120
|
|
|
117
|
-
#
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
# # Test API key with a simple request
|
|
121
|
-
# client = PingeraClient.from_api_key(active_api_key)
|
|
122
|
-
# # Make a test request
|
|
123
|
-
# status_content += "\n[bold]API Status:[/bold] [green]✅ Valid[/green]"
|
|
124
|
-
# except Exception as e:
|
|
125
|
-
# status_content += f"\n[bold]API Status:[/bold] [red]❌ Invalid ({str(e)})[/red]"
|
|
121
|
+
# Validate API key
|
|
122
|
+
validation_status = self._validate_api_key(active_api_key)
|
|
123
|
+
status_content += f"\nAPI Key Check: {validation_status}"
|
|
126
124
|
|
|
127
125
|
else:
|
|
128
126
|
status_content = """
|
|
@@ -209,6 +207,48 @@ API Key: ✗ Not set
|
|
|
209
207
|
self.display_error(f"Logout failed: {str(e)}")
|
|
210
208
|
raise typer.Exit(1)
|
|
211
209
|
|
|
210
|
+
def _validate_api_key(self, api_key: str) -> str:
|
|
211
|
+
"""
|
|
212
|
+
Validate API key by making a test request
|
|
213
|
+
|
|
214
|
+
Args:
|
|
215
|
+
api_key: The API key to validate
|
|
216
|
+
|
|
217
|
+
Returns:
|
|
218
|
+
str: Formatted status message
|
|
219
|
+
"""
|
|
220
|
+
try:
|
|
221
|
+
# Import here to avoid circular imports and handle missing SDK gracefully
|
|
222
|
+
from pingera import ApiClient, Configuration
|
|
223
|
+
from pingera.api import ChecksApi
|
|
224
|
+
from pingera.exceptions import UnauthorizedException
|
|
225
|
+
|
|
226
|
+
# Configure the client (same pattern as checks command)
|
|
227
|
+
configuration = Configuration()
|
|
228
|
+
configuration.host = "https://api.pingera.ru"
|
|
229
|
+
configuration.api_key['apiKeyAuth'] = api_key
|
|
230
|
+
|
|
231
|
+
# Create API client
|
|
232
|
+
api_client = ApiClient(configuration)
|
|
233
|
+
checks_api = ChecksApi(api_client)
|
|
234
|
+
|
|
235
|
+
# Make a lightweight test request to validate the API key
|
|
236
|
+
checks_api.v1_checks_get()
|
|
237
|
+
|
|
238
|
+
return "[green]✅ Valid[/green]"
|
|
239
|
+
|
|
240
|
+
except ImportError:
|
|
241
|
+
return "[yellow]⚠ Cannot validate (Pingera SDK not available)[/yellow]"
|
|
242
|
+
except UnauthorizedException:
|
|
243
|
+
return "[red]❌ Invalid or expired[/red]"
|
|
244
|
+
except Exception as e:
|
|
245
|
+
# Handle other API errors gracefully
|
|
246
|
+
error_msg = str(e).lower()
|
|
247
|
+
if "network" in error_msg or "connection" in error_msg or "timeout" in error_msg:
|
|
248
|
+
return "[yellow]⚠ Cannot validate (network error)[/yellow]"
|
|
249
|
+
else:
|
|
250
|
+
return f"[yellow]⚠ Cannot validate ({str(e)})[/yellow]"
|
|
251
|
+
|
|
212
252
|
|
|
213
253
|
# Create the auth command instance
|
|
214
254
|
auth_cmd = AuthCommand()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|