# Path: alertaclient/utils.py
# def origin():
#     prog = os.path.basename(sys.argv[0])
#     return f'{prog}/{platform.uname()[1]}'


import json
import click
from datetime import datetime, timedelta
from tabulate import tabulate
from alertaclient.utils import origin
                elif b['status'] == 'active':
                    expiration = datetime.fromisoformat(b['expireTime'].split('.')[0])
                    remaining_validity = expiration - datetime.now()
                    if remaining_validity < timedelta(days=maxage):
                        client.send_alert(
                            resource=b['id'],
                            event='ApiKeyExpiring',
                            environment=environment,
                            severity=severity,
                            correlate=['ApiKeyExpired', 'ApiKeyExpiring', 'ApiKeyOK'],
                            service=service,
                            group=group,
                            value=str(remaining_validity),
                            text=f"Key is active and expires on {b['expireTime']}",
                            origin=origin(),
                            type='apiKeyAlert',
                            timeout=timeout,
                            customer=b['customer']
                        )
                    else:
                        client.send_alert(
                            resource=b['id'],
                            event='ApiKeyOK',
                            environment=environment,
                            severity='ok',
                            correlate=['ApiKeyExpired', 'ApiKeyExpiring', 'ApiKeyOK'],
                            service=service,
                            group=group,
                            value=str(remaining_validity),
                            text=f"Key is active and expires on {b['expireTime']}",

# Path: alertaclient/utils.py
# def origin():
#     prog = os.path.basename(sys.argv[0])
#     return f'{prog}/{platform.uname()[1]}'


# Path: alertaclient/commands/cmd_keys.py
import json
import click
from datetime import datetime, timedelta
from tabulate import tabulate
from alertaclient.utils import origin

                elif b['status'] == 'active':
                    expiration = datetime.fromisoformat(b['expireTime'].split('.')[0])
                    remaining_validity = expiration - datetime.now()
                    if remaining_validity < timedelta(days=maxage):
                        client.send_alert(
                            resource=b['id'],
                            event='ApiKeyExpiring',
                            environment=environment,
                            severity=severity,
                            correlate=['ApiKeyExpired', 'ApiKeyExpiring', 'ApiKeyOK'],
                            service=service,
                            group=group,
                            value=str(remaining_validity),
                            text=f"Key is active and expires on {b['expireTime']}",
                            origin=origin(),
                            type='apiKeyAlert',
                            timeout=timeout,
                            customer=b['customer']
                        )
                    else:
                        client.send_alert(
                            resource=b['id'],
                            event='ApiKeyOK',
                            environment=environment,
                            severity='ok',
                            correlate=['ApiKeyExpired', 'ApiKeyExpiring', 'ApiKeyOK'],
                            service=service,
                            group=group,
                            value=str(remaining_validity),
                            text=f"Key is active and expires on {b['expireTime']}",

                            origin=origin(),