Remove opaque_id from the client constructor
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
ELASTICSEARCH_VERSION:
|
ELASTICSEARCH_VERSION:
|
||||||
- 7.x-SNAPSHOT
|
- 7.6-SNAPSHOT
|
||||||
|
|
||||||
TEST_SUITE:
|
TEST_SUITE:
|
||||||
- oss
|
- oss
|
||||||
|
|||||||
+4
-5
@@ -70,13 +70,12 @@ or to help with `identifying running tasks <https://www.elastic.co/guide/en/elas
|
|||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
import elasticsearch
|
from elasticsearch import Elasticsearch
|
||||||
|
|
||||||
# You can add to the client to apply to all requests
|
client = Elasticsearch()
|
||||||
client = elasticsearch.Elasticsearch(opaque_id="[email protected]_user1234")
|
|
||||||
|
|
||||||
# Or you can apply per-request for more granularity.
|
# You can apply X-Opaque-Id in any API request via 'opaque_id':
|
||||||
resp = client.get(index="test", id="1", opaque_id="[email protected]_user1234")
|
resp = client.get(index="test", id="1", opaque_id="request-1")
|
||||||
|
|
||||||
|
|
||||||
.. py:module:: elasticsearch
|
.. py:module:: elasticsearch
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ class Connection(object):
|
|||||||
http_compress=None,
|
http_compress=None,
|
||||||
cloud_id=None,
|
cloud_id=None,
|
||||||
api_key=None,
|
api_key=None,
|
||||||
opaque_id=None,
|
|
||||||
**kwargs
|
**kwargs
|
||||||
):
|
):
|
||||||
|
|
||||||
@@ -89,8 +88,6 @@ class Connection(object):
|
|||||||
headers = headers or {}
|
headers = headers or {}
|
||||||
for key in headers:
|
for key in headers:
|
||||||
self.headers[key.lower()] = headers[key]
|
self.headers[key.lower()] = headers[key]
|
||||||
if opaque_id:
|
|
||||||
self.headers["x-opaque-id"] = opaque_id
|
|
||||||
|
|
||||||
self.headers.setdefault("content-type", "application/json")
|
self.headers.setdefault("content-type", "application/json")
|
||||||
self.headers.setdefault("user-agent", self._get_default_user_agent())
|
self.headers.setdefault("user-agent", self._get_default_user_agent())
|
||||||
|
|||||||
@@ -119,10 +119,6 @@ class TestUrllib3Connection(TestCase):
|
|||||||
self.assertIsInstance(con.pool.conn_kw["ssl_context"], ssl.SSLContext)
|
self.assertIsInstance(con.pool.conn_kw["ssl_context"], ssl.SSLContext)
|
||||||
self.assertTrue(con.use_ssl)
|
self.assertTrue(con.use_ssl)
|
||||||
|
|
||||||
def test_opaque_id(self):
|
|
||||||
con = Urllib3HttpConnection(opaque_id="app-1")
|
|
||||||
self.assertEqual(con.headers["x-opaque-id"], "app-1")
|
|
||||||
|
|
||||||
def test_http_cloud_id(self):
|
def test_http_cloud_id(self):
|
||||||
con = Urllib3HttpConnection(
|
con = Urllib3HttpConnection(
|
||||||
cloud_id="cluster:dXMtZWFzdC0xLmF3cy5mb3VuZC5pbyQ0ZmE4ODIxZTc1NjM0MDMyYmVkMWNmMjIxMTBlMmY5NyQ0ZmE4ODIxZTc1NjM0MDMyYmVkMWNmMjIxMTBlMmY5Ng=="
|
cloud_id="cluster:dXMtZWFzdC0xLmF3cy5mb3VuZC5pbyQ0ZmE4ODIxZTc1NjM0MDMyYmVkMWNmMjIxMTBlMmY5NyQ0ZmE4ODIxZTc1NjM0MDMyYmVkMWNmMjIxMTBlMmY5Ng=="
|
||||||
@@ -398,10 +394,6 @@ class TestRequestsConnection(TestCase):
|
|||||||
con = RequestsHttpConnection(timeout=42)
|
con = RequestsHttpConnection(timeout=42)
|
||||||
self.assertEquals(42, con.timeout)
|
self.assertEquals(42, con.timeout)
|
||||||
|
|
||||||
def test_opaque_id(self):
|
|
||||||
con = RequestsHttpConnection(opaque_id="app-1")
|
|
||||||
self.assertEqual(con.headers["x-opaque-id"], "app-1")
|
|
||||||
|
|
||||||
def test_http_cloud_id(self):
|
def test_http_cloud_id(self):
|
||||||
con = RequestsHttpConnection(
|
con = RequestsHttpConnection(
|
||||||
cloud_id="cluster:dXMtZWFzdC0xLmF3cy5mb3VuZC5pbyQ0ZmE4ODIxZTc1NjM0MDMyYmVkMWNmMjIxMTBlMmY5NyQ0ZmE4ODIxZTc1NjM0MDMyYmVkMWNmMjIxMTBlMmY5Ng=="
|
cloud_id="cluster:dXMtZWFzdC0xLmF3cy5mb3VuZC5pbyQ0ZmE4ODIxZTc1NjM0MDMyYmVkMWNmMjIxMTBlMmY5NyQ0ZmE4ODIxZTc1NjM0MDMyYmVkMWNmMjIxMTBlMmY5Ng=="
|
||||||
|
|||||||
Reference in New Issue
Block a user