Es-client

Latest version: v8.12.9

Safety actively analyzes 613460 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 7

8.12.9

**Bugfix**

* Reported in [Curator 1708](https://github.com/elastic/curator/issues/1708). Default values (rather than None values) were overriding what was in config files. As a result, these default values from command-line settings were overriding important settings which were set properly in the configuration file. Hat tip to rgaduput for reporting this.

**Changes**

* Updated cli_example.py to make the ``show_all_options`` sub-command show the proper environment variables. This entailed resetting the context_settings. A note explaining the why is now in the comments above that function.
* Updates to reflect the default values in the command-line were made in the tutorial and example documentation pages.
* A new documentation page was created specific to environment variables.
* Version bump ``voluptuous==0.14.2`` from ``0.14.1``

8.12.8

----------------------

**Bugfix**

* Really batting 1000 today. Missed some version bumps.

8.12.7

**Bugfix**

* Erroneously removed ``six`` dependency. It's back at ``1.16.0``.

8.12.6

**Changes**

* After reading and re-reading through the tutorial, I made a few doc changes.
* ``ctx.obj`` is instantiated in ``helpers.config.context_settings`` now, saving yet another
line of code from being needed in a functional command-line script.
* Decided it was actually time to programmatically approach the huge list of decorators necessary
to make ``es_client`` work in the example. Now there's a single decorator,
``options_from_dict()`` in ``helpers.config``, and it takes a dictionary as an argument. The
form of this dictionary should be:
python
{
"option1": {"onoff": {}, "override": {}, "settings": {}},
"option2": {"onoff": {}, "override": {}, "settings": {}},
...
"optionN": {"onoff": {}, "override": {}, "settings": {}},
}

The defaults are provided in ``helpers.defaults`` as constants ``OPTION_DEFAULTS`` and ``SHOW_EVERYTHING``. These can be overridden programmatically or very tediously manually.

* Dependency version bumps:

python
elasticsearch8==8.12.1
certifi==2024.2.2

8.12.5

**Changes**

After some usage, it seems wise to remove redundancy in calling params and config in the functions
in ``helpers.config``. This is especially true since ``ctx`` already has all of the params, and
``ctx.params['config']`` has the config file (if specified).

It necessitated a more irritating revamp of the tests to make it work (why, Click? Why can't a
Context be provided and just work?), but it does work cleanly now, with those clean looking
function calls.

New standards include:

* ENVIRONMENT VARIABLE SUPPORT. Very big. Suffice to say that all command-line options can now
be set by an environment variable by putting the prefix ``ESCLIENT_`` in front of the uppercase
option name, and replace any hyphens with underscores. ``--http-compress True`` is settable by
having ``ESCLIENT_HTTP_COMPRESS=1``. Boolean values are 1, 0, True, or False (case-insensitive).
Options like ``hosts`` which can have multiple values just need to have whitespace between the
values:

.. code-block:: shell

ESCLIENT_HOSTS='http://127.0.0.1:9200 http://localhost:9200'

It splits perfectly. This is big news for the containerization/k8s community. You won't have to
have all of the options spilled out any more. Just have the environment variables assigned.
* ``ctx.obj['default_config']`` will be the place to insert a default configuration file
_before_ calling ``helpers.config.get_config()``.
* ``helpers.config.get_arg_objects()`` will now set ``ctx.obj['client_args'] = ClientArgs()``
and ``ctx.obj['other_args'] = OtherArgs()``, where they become part of ``ctx.obj`` and are
accessible thereby.
* ``helpers.config.generate_configdict`` will now populate ``ctx.obj['configdict']``
* ``Builder(configdict=ctx.obj['configdict'])`` will work, as will
``helpers.config.get_client(configdict=ctx.obj['configdict'])``

In fact, this has been so simplified now that the flow of a command-line app is as simple as:

.. code-block:: python

def myapp(ctx, *args):
ctx.obj = {}
ctx.obj['default_config'] = '/path/to/cfg.yaml'
get_config(ctx)
configure_logging(ctx)
generate_configdict(ctx)
es_client = get_client(configdict=ctx.obj['configdict'])
Your other code...

Additionally, the log blacklist functionality has been added to the command-line, the default
settings, the ``helpers.logging`` module, and the ``cli_example``, which should be welcome news to
the containerized world.

Major work to standardize the documentation has also been undertaken. In fact, there is now a
tutorial on how to make a command-line app in the documentation.

8.12.4

**Fixes**

The try/except block for Docker logging needed to be out one level farther.

This should fix the permissions error issues at last.

Page 1 of 7

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.