Example #1
0
def cli(obj, ids, query, filters, text):
    """Set alert status to 'open'."""
    client = obj['client']
    if ids:
        total = len(ids)
    else:
        if query:
            query = [('q', query)]
        else:
            query = build_query(filters)
        total, _, _ = client.get_count(query)
        ids = [a.id for a in client.get_alerts(query)]

    action_progressbar(client, 'unshelve', ids, label='Un-shelving {} alerts'.format(total), text=text)
Example #2
0
def cli(obj, ids, query, filters, text):
    """Set alert status to 'closed'."""
    client = obj['client']
    if ids:
        total = len(ids)
    else:
        if query:
            query = [('q', query)]
        else:
            query = build_query(filters)
        total, _, _ = client.get_count(query)
        ids = [a.id for a in client.get_alerts(query)]

    action_progressbar(client, action='close', ids=ids, label=f'Closing {total} alerts', text=text)
Example #3
0
def cli(obj, action, ids, query, filters, text):
    """Take action on alert'."""
    client = obj['client']
    if ids:
        total = len(ids)
    else:
        if query:
            query = [('q', query)]
        else:
            query = build_query(filters)
        total, _, _ = client.get_count(query)
        ids = [a.id for a in client.get_alerts(query)]

    label = 'Action ({}) {} alerts'.format(action, total)
    action_progressbar(client, action=action, ids=ids, label=label, text=text)
Example #4
0
def cli(obj, action, ids, query, filters, text):
    """Take action on alert'."""
    client = obj['client']
    if ids:
        total = len(ids)
    else:
        if query:
            query = [('q', query)]
        else:
            query = build_query(filters)
        total, _, _ = client.get_count(query)
        ids = [a.id for a in client.get_alerts(query)]

    action_text = re.sub('([A-Z])', r' \1',
                         action).title()  # 'createIssue' => 'Create Issue'
    label = 'Action {} {} alerts'.format(action, total)
    text = text or '{} using CLI'.format(action_text)
    action_progressbar(client, action=action, ids=ids, label=label, text=text)