Skip to main content

"Elasticsearch Client builder, complete with schema validation, and AWS boto-based authentication"

Project description

You may wonder why this even exists, as at first glance it doesn’t seem to make anything any easier than just using elasticsearch.Elasticsearch() to build a client connection. I needed to be able to reuse the more complex schema validation bits I was employing, namely:

  • master_only detection

  • AWS IAM credential collection via boto3.session.Session

  • Elasticsearch version checking and validation, and the option to skip this.

  • Configuration value validation, including file paths for SSL certificates, meaning:

    • No unknown keys or unacceptable parameter values are accepted

    • Acceptable values and ranges are established–and easy to amend, if necessary.

So, if you don’t need these, then this library probably isn’t what you’re looking for. If you want these features, then you’ve come to the right place.

Example Usage

from es_client import Builder

config = {
    'elasticsearch': {
        'master_only': True,
        'client': {
            'hosts': '10.0.0.123',
            'use_ssl': True,
            'ca_certs': '/etc/elasticsearch/certs/ca.crt',
            'username': 'joe_user',
            'password': 'password',
            'timeout': 60,
        }
    }
}

try:
    client = Builder(config).client
except:
    # Do exception handling here...

Additionally, you can read from a YAML configuration file:

---
elasticsearch:
  master_only: true
  client:
    hosts: 10.0.0.123
    use_ssl: true
    ca_certs: /etc/elasticsearch/certs/ca.crt
    username: joe_user
    password: password
    timeout: 60
from es_client import Builder
from es_client.exceptions import ConfigurationError
from es_client.helpers.utils import get_yaml

try:
    client = Builder(get_yaml('/path/to/es_client.yml').client
except:
    # Do exception handling here...

The same schema validations apply here as well.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

es_client-1.1.1.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

es_client-1.1.1-py2.py3-none-any.whl (11.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file es_client-1.1.1.tar.gz.

File metadata

  • Download URL: es_client-1.1.1.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for es_client-1.1.1.tar.gz
Algorithm Hash digest
SHA256 c2ac52222407149aca19adf4d94c6e2a65f618885b728486b5e1d92319d1031d
MD5 990b2cd4a941a515aa9620b580205043
BLAKE2b-256 728950a23fcccd12fc57ce929eb1a8ede768319aae728de3237e576c51c41462

See more details on using hashes here.

File details

Details for the file es_client-1.1.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for es_client-1.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 604cf350675f0e4a06c85c371055e5f3c4243b404f61f80592fe3f623c6a88fe
MD5 f94c02cc4409e4ee0d76205f2071000d
BLAKE2b-256 5c04987393ba4cbb3afcc8ff0d115178c833e4acfb25550ce08ac47bbb071428

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page