Es-client

Latest version: v8.13.5

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

Scan your dependencies

Page 1 of 8

8.13.5

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

**Changes**

* Version bump for ``elasticsearch8==8.13.1``
* Code formatting changes (cleanup of lines over 88 chars, mostly).
* Added ``.coveragerc``
* Improved ``docker_test`` scripts and env var importing in tests.

**Bugfix**

* Discovered an instance where passwords were being logged. This has been corrected.

8.13.4

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

**Changes**

* Updated ``docker_test`` scripts to enable TLS testing and better integration with pytest.
TEST_USER and TEST_PASS and TEST_ES_SERVER, etc. are all populated and put into ``.env``
Even the CA certificate is copied to TEST_PATH, so it's easy for the tests to pick it up.
Not incidentally, the scripts were moved from ``docker_test/scripts`` to just ``docker_test``.
The tutorial in the documentation has been updated to reflect these changes.
* Added ``pytest-dotenv`` as a test dependency to take advantage of the ``.env``
* Minor code formatting in most files as I've switched to using ``black`` with VS Code, and
flake8, and mypy.

**Bugfix**

* Found 1 stray instance of ``update_settings`` from before the DotMap switch. Fixed.

8.13.3

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

**Changes**

* After all that work to ensure proper typing, I forgot to include the ``py.typed`` marker file.

8.13.2

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

**Changes**

* Added typing hints, everywhere. Trying to make the module play nicer with others.
* Moved all code under ``src/es_client`` to be more package compliant.
* Moved ``__version__`` to ``__init__.py``
* Updated the ``pyproject.toml`` file to reflect these changes.
* Updated tests and documentation as needed.

**Potentially Breaking Changes**

* Migrated away from custom ``dict``-to-attribute class ``Args`` to ``DotMap``. It's the best of
both worlds as it gives full dotted notation access to a dictionary, making it appear like
class attributes. But it also still affords you the ability to treat each nested field just like
a dictionary, still. ``Builder.client_args`` and ``Builder.other_args`` should look and feel the
exact same as before, with one noted difference, and that is the ``.asdict()`` method has been
replaced by the ``.toDict()`` method. This is the one change that might mess you up. If you
are using that anywhere, please replace those calls. Also, if you were manually building these
objects before, rather than supplying a config file or dict, you can create these now as
follows:

.. code-block:: python

from es_client import Builder
from dotmap import DotMap

client_settings = {} Filled with your client settings
client_args = DotMap(client_settings)

builder = Builder()
builder.client_args = client_args
Or directly assign:
builder.client_args = DotMap(client_settings)

Updating a single key is simple:

.. code-block:: python

other_args = DotMap(other_settings)
other_args.username = 'nobody'
other_args['password'] = 'The Spanish Inquisition'

As noted, both dotted and dict formats are acceptable, as demonstrated above.
Updating with a dictionary of root level keys is simple:

.. code-block:: python

other_settings = {
'master_only': False,
'username': 'original',
'password': 'oldpasswd',
}
other_args = DotMap(other_settings)
DotMap(master_only=False, username='original', password='oldpasswd')
changes = {
'master_only': True,
'username': 'newuser',
'password': 'newpasswd',
}
other_args.update(changes)
DotMap(master_only=True, username='newuser', password='newpasswd')

If putting a nested dictionary in place, you should convert it to a DotMap first:

.. code-block:: python

d = {'a':'A', 'b':{'c':'C', 'd':{'e':'E'}}}
dm = DotMap(d)
DotMap(a='A', b=DotMap(c='C', d=DotMap(e='E')))
b = {'b':{'g':'G', 'h':{'i':'I'}}}
dm.update(b)
DotMap(a='A', b={'g': 'G', 'h': {'i': 'I'}})
^^^
Not a DotMap
dm.update(DotMap(b))
DotMap(a='A', b=DotMap(g='G', h=DotMap(i='I')))

It's always safest to update with a DotMap rather than a bare dict.
That's about it.

8.13.1

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

**Bugfix**

* Reported in 60. Newer code changes do not work properly with Python versions < 3.10 due to
changes to dictionary annotations. The offending code has been patched to work around this.

**Announcement**

* Added infrastructure to test multiple versions of Python against the code base. This requires
you to run ``pip install -U hatch hatchling``, and then ``hatch run test:test``. integration
tests will fail if you do not have a local Elasticsearch running (see the
``docker_test/scripts`` directory for some help with that).

8.13.0

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

**Changes**

* Version bump: ``elasticsearch8==8.13.0``

Page 1 of 8

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.