How to use the anchorecli.clients.apiexternal.get_account function in anchorecli

To help you get started, we’ve selected a few anchorecli examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github anchore / anchore-cli / anchorecli / cli / account.py View on Github external
def account(ctx_config):
    global config, whoami
    config = ctx_config

    try:
        anchorecli.cli.utils.check_access(config)
    except Exception as err:
        print(anchorecli.cli.utils.format_error_output(config, 'account', {}, err))
        sys.exit(2)

    try:
        ret = anchorecli.clients.apiexternal.get_account(config)
        if ret['success']:
            whoami['account'] = ret['payload']
        else:
            raise Exception( json.dumps(ret['error'], indent=4))
    except Exception as err:
        print(anchorecli.cli.utils.format_error_output(config, 'account', {}, err))
        sys.exit(2)

    try:
        ret = anchorecli.clients.apiexternal.get_user(config)
        if ret['success']:
            whoami['user'] = ret['payload']
        else:
            raise Exception( json.dumps(ret['error'], indent=4))
    except Exception as err:
        print(anchorecli.cli.utils.format_error_output(config, 'account', {}, err))
github anchore / anchore-cli / anchorecli / cli / account.py View on Github external
def get(account_name):
    """
    ACCOUNT_NAME: name of new account to create

    """
    ecode = 0

    try:
        ret = anchorecli.clients.apiexternal.get_account(config, account_name=account_name)
        ecode = anchorecli.cli.utils.get_ecode(ret)
        if ret['success']:
            print(anchorecli.cli.utils.format_output(config, 'account_get', {}, ret['payload']))
        else:
            raise Exception( json.dumps(ret['error'], indent=4))

    except Exception as err:
        print(anchorecli.cli.utils.format_error_output(config, 'account_get', {}, err))
        if not ecode:
            ecode = 2

    anchorecli.cli.utils.doexit(ecode)