Coverage for curator/cli_singletons/alias.py: 100%
16 statements
« prev ^ index » next coverage.py v7.3.0, created at 2023-08-16 15:27 -0600
« prev ^ index » next coverage.py v7.3.0, created at 2023-08-16 15:27 -0600
1"""Alias Singleton"""
2import click
3from curator.cli_singletons.object_class import cli_action
4from curator.cli_singletons.utils import get_width, json_to_dict, validate_filter_json
6@click.command(context_settings=get_width())
7@click.option('--name', type=str, help='Alias name', required=True)
8@click.option(
9 '--add',
10 callback=validate_filter_json,
11 help='JSON array of filters selecting indices to ADD to alias',
12 default=None
13)
14@click.option(
15 '--remove',
16 callback=validate_filter_json,
17 help='JSON array of filters selecting indices to REMOVE from alias',
18 default=None
19)
20@click.option(
21 '--warn_if_no_indices',
22 is_flag=True,
23 help='Do not raise exception if there are no actionable indices in add/remove'
24)
25@click.option(
26 '--extra_settings',
27 help='JSON version of extra_settings (see documentation)',
28 callback=json_to_dict
29)
30@click.option(
31 '--allow_ilm_indices/--no-allow_ilm_indices',
32 help='Allow Curator to operate on Index Lifecycle Management monitored indices.',
33 default=False,
34 show_default=True
35)
36@click.pass_context
37def alias(ctx, name, add, remove, warn_if_no_indices, extra_settings, allow_ilm_indices):
38 """
39 Add/Remove Indices to/from Alias
40 """
41 manual_options = {
42 'name': name,
43 'extra_settings': extra_settings,
44 'allow_ilm_indices': allow_ilm_indices,
45 }
46 # ctx.info_name is the name of the function or name specified in @click.command decorator
47 ignore_empty_list = warn_if_no_indices
48 action = cli_action(
49 ctx.info_name,
50 ctx.obj['config']['client'],
51 manual_options,
52 [], # filter_list is empty in our case
53 ignore_empty_list,
54 add=add, remove=remove, warn_if_no_indices=warn_if_no_indices, # alias specific kwargs
55 )
56 action.do_singleton_action(dry_run=ctx.obj['dry_run'])