data-anaxi/anaxi/cli.py
2024-08-09 14:45:10 +02:00

49 lines
1.2 KiB
Python

import importlib.metadata
import click
import pyfiglet
from anaxi.logging import get_anaxi_logger
from anaxi.processes import (
run_cosmos_db_healthcheck_process,
run_postgres_healthcheck_process,
)
logger = get_anaxi_logger(__name__)
@click.group()
def cli():
logger.info(pyfiglet.figlet_format("\nWelcome to anaxi", font="big"))
logger.info(f"Running anaxi version: {importlib.metadata.version('anaxi')}")
@cli.command()
def smoke_test():
print("Oink oink!")
print(
"""
__,---.__
,-' `-.__
&/ `._\ _\\
/ ''._
| , (")
|__,'`-..--|__|--''
"""
)
@cli.command()
@click.option("--cosmos-db-id", type=click.STRING, required=True)
def cosmos_db_healthcheck(cosmos_db_id):
logger.info("Starting a Cosmos DB healthcheck.")
run_cosmos_db_healthcheck_process(cosmos_db_id)
logger.info("Finished the Cosmos DB healthcheck.")
@cli.command()
@click.option("--postgres-database", type=click.STRING, required=True)
def postgres_healthcheck(postgres_database):
logger.info("Starting a Postgres healthcheck.")
run_postgres_healthcheck_process(postgres_database)
logger.info("Finished the Postgres healthcheck.")