From e74457866de99975977e8a86ee35086fcf2ed1c7 Mon Sep 17 00:00:00 2001 From: Nick Lang Date: Thu, 28 Dec 2017 12:08:55 -0700 Subject: [PATCH] updating the docs some more examples --- README | 16 ++++++++++++++++ docs/connection.rst | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/README b/README index 199b137f..8a0b360d 100644 --- a/README +++ b/README @@ -88,6 +88,22 @@ Simple use-case:: .. _Full documentation: https://elasticsearch-py.readthedocs.io/ +Elastic Cloud (and SSL) use-case:: + + >>> from elasticsearch import Elasticsearch + >>> es = Elasticsearch("https://elasticsearch.url:port", http_auth=('elastic','yourpassword')) + >>> es.info() + +Using SSL Context with a self-signed cert use-case:: + + >>> from elasticsearch import Elasticsearch + >>> from elasticsearch.connection.http_urllib3 import create_ssl_context + + >>> context = create_ssl_context(cafile="path/to/cafile.pem") + >>> es = Elasticsearch("https://elasticsearch.url:port", ssl_context=context, http_auth=('elastic','yourpassword')) + >>> es.info() + + Features -------- diff --git a/docs/connection.rst b/docs/connection.rst index 7f5743e2..8bccce36 100644 --- a/docs/connection.rst +++ b/docs/connection.rst @@ -54,6 +54,14 @@ If you want to create your own `SSLContext` object you can create one natively u python SSL library with the `create_default_context` (https://docs.python.org/3/library/ssl.html#ssl.create_default_context) method or you can use the wrapper function :function:`~elasticsearch.connection.http_urllib3.create_ssl_context`. +To create an `SSLContext` object you only need to use one of cafile, capath or cadata:: + + >>> from elasticsearch.connection.http_urllib3 import create_ssl_context + >>> context = create_ssl_context(cafile=None, capath=None, cadata=None) + +* `cafile` is the path to your CA File +* `capath` is the directory of a collection of CA's +* `cadata` is either an ASCII string of one or more PEM-encoded certificates or a bytes-like object of DER-encoded certificates. .. autoclass:: Urllib3HttpConnection :members: