File: singletons.py

package info (click to toggle)
elasticsearch-curator 8.0.21-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,716 kB
  • sloc: python: 17,838; makefile: 159; sh: 156
file content (105 lines) | stat: -rw-r--r-- 2,586 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
"""CLI module for curator_cli"""

import click
from es_client.defaults import SHOW_EVERYTHING
from es_client.helpers.config import (
    cli_opts,
    context_settings,
    generate_configdict,
    get_config,
    options_from_dict,
)
from es_client.helpers.logging import configure_logging
from es_client.helpers.utils import option_wrapper
from curator.defaults.settings import CLICK_DRYRUN, default_config_file, footer
from curator._version import __version__
from curator.cli_singletons import (
    alias,
    allocation,
    close,
    delete_indices,
    delete_snapshots,
    forcemerge,
    open_indices,
    replicas,
    restore,
    rollover,
    snapshot,
    shrink,
)
from curator.cli_singletons.show import show_indices, show_snapshots

click_opt_wrap = option_wrapper()


# pylint: disable=R0913, R0914, W0613, W0622, W0718
@click.group(
    context_settings=context_settings(),
    epilog=footer(__version__, tail='singleton-cli.html'),
)
@options_from_dict(SHOW_EVERYTHING)
@click_opt_wrap(*cli_opts('dry-run', settings=CLICK_DRYRUN))
@click.version_option(__version__, '-v', '--version', prog_name='curator_cli')
@click.pass_context
def curator_cli(
    ctx,
    config,
    hosts,
    cloud_id,
    api_token,
    id,
    api_key,
    username,
    password,
    bearer_auth,
    opaque_id,
    request_timeout,
    http_compress,
    verify_certs,
    ca_certs,
    client_cert,
    client_key,
    ssl_assert_hostname,
    ssl_assert_fingerprint,
    ssl_version,
    master_only,
    skip_version_test,
    loglevel,
    logfile,
    logformat,
    blacklist,
    dry_run,
):
    """
    Curator CLI (Singleton Tool)

    Run a single action from the command-line.

    The default $HOME/.curator/curator.yml configuration file (--config)
    can be used but is not needed.

    Command-line settings will always override YAML configuration settings.
    """
    ctx.obj = {}
    ctx.obj['dry_run'] = dry_run
    ctx.obj['default_config'] = default_config_file()
    get_config(ctx)
    configure_logging(ctx)
    generate_configdict(ctx)


# Add the subcommands
curator_cli.add_command(alias)
curator_cli.add_command(allocation)
curator_cli.add_command(close)
curator_cli.add_command(delete_indices)
curator_cli.add_command(delete_snapshots)
curator_cli.add_command(forcemerge)
curator_cli.add_command(open_indices)
curator_cli.add_command(replicas)
curator_cli.add_command(snapshot)
curator_cli.add_command(restore)
curator_cli.add_command(rollover)
curator_cli.add_command(shrink)
curator_cli.add_command(show_indices)
curator_cli.add_command(show_snapshots)