removes elastic support from opensearch-py library

Signed-off-by: Shivam Dhar <[email protected]>
This commit is contained in:
Shivam Dhar
2022-01-05 22:22:43 +05:30
committed by Shivam Dhar
parent d1179968a8
commit cfe1190a22
14 changed files with 2 additions and 384 deletions
-7
View File
@@ -95,8 +95,6 @@ class AIOHttpConnection(AsyncConnection):
headers=None,
ssl_context=None,
http_compress=None,
cloud_id=None,
api_key=None,
opaque_id=None,
loop=None,
**kwargs,
@@ -130,9 +128,6 @@ class AIOHttpConnection(AsyncConnection):
information.
:arg headers: any custom http headers to be add to requests
:arg http_compress: Use gzip compression
:arg cloud_id: The Cloud ID from ElasticCloud. Convenient way to connect to cloud instances.
Other host connection params will be ignored.
:arg api_key: optional API Key authentication as either base64 encoded string or a tuple.
:arg opaque_id: Send this value in the 'X-Opaque-Id' HTTP header
For tracing all requests made by this transport.
:arg loop: asyncio Event Loop to use with aiohttp. This is set by default to the currently running loop.
@@ -146,8 +141,6 @@ class AIOHttpConnection(AsyncConnection):
use_ssl=use_ssl,
headers=headers,
http_compress=http_compress,
cloud_id=cloud_id,
api_key=api_key,
opaque_id=opaque_id,
**kwargs,
)
-2
View File
@@ -62,8 +62,6 @@ class AIOHttpConnection(AsyncConnection):
headers: Optional[Mapping[str, str]] = ...,
ssl_context: Optional[Any] = ...,
http_compress: Optional[bool] = ...,
cloud_id: Optional[str] = ...,
api_key: Optional[Any] = ...,
opaque_id: Optional[str] = ...,
loop: Any = ...,
**kwargs: Any,
-4
View File
@@ -99,10 +99,6 @@ class AsyncTransport(Transport):
*args, hosts=[], sniff_on_start=False, **kwargs
)
# Don't enable sniffing on Cloud instances.
if kwargs.get("cloud_id", False):
sniff_on_start = False
# Since we defer connections / sniffing to not occur
# within the constructor we never want to signal to
# our parent to 'sniff_on_start' or non-empty 'hosts'.
+2 -48
View File
@@ -24,7 +24,6 @@
# specific language governing permissions and limitations
# under the License.
import binascii
import gzip
import io
import logging
@@ -39,12 +38,7 @@ except ImportError:
import json
from .. import __versionstr__
from ..exceptions import (
HTTP_EXCEPTIONS,
ImproperlyConfigured,
OpenSearchWarning,
TransportError,
)
from ..exceptions import HTTP_EXCEPTIONS, OpenSearchWarning, TransportError
logger = logging.getLogger("opensearch")
@@ -72,7 +66,6 @@ class Connection(object):
:arg url_prefix: optional url prefix for opensearch
:arg timeout: default timeout in seconds (float, default: 10)
:arg http_compress: Use gzip compression
:arg cloud_id: The Cloud ID from ElasticCloud. Convenient way to connect to cloud instances.
:arg opaque_id: Send this value in the 'X-Opaque-Id' HTTP header
For tracing all requests made by this transport.
"""
@@ -86,35 +79,10 @@ class Connection(object):
timeout=10,
headers=None,
http_compress=None,
cloud_id=None,
api_key=None,
opaque_id=None,
**kwargs
):
if cloud_id:
try:
_, cloud_id = cloud_id.split(":")
parent_dn, opensearch_uuid = (
binascii.a2b_base64(cloud_id.encode("utf-8"))
.decode("utf-8")
.split("$")[:2]
)
if ":" in parent_dn:
parent_dn, _, parent_port = parent_dn.rpartition(":")
if port is None and parent_port != "443":
port = int(parent_port)
except (ValueError, IndexError):
raise ImproperlyConfigured("'cloud_id' is not properly formatted")
host = "%s.%s" % (opensearch_uuid, parent_dn)
use_ssl = True
if http_compress is None:
http_compress = True
# If cloud_id isn't set and port is default then use 9200.
# Cloud should use '443' by default via the 'https' scheme.
elif port is None:
if port is None:
port = 9200
# Work-around if the implementing class doesn't
@@ -136,9 +104,6 @@ class Connection(object):
self.headers.setdefault("content-type", "application/json")
self.headers.setdefault("user-agent", self._get_default_user_agent())
if api_key is not None:
self.headers["authorization"] = self._get_api_key_header_val(api_key)
if http_compress:
self.headers["accept-encoding"] = "gzip,deflate"
@@ -338,14 +303,3 @@ class Connection(object):
def _get_default_user_agent(self):
return "opensearch-py/%s (Python %s)" % (__versionstr__, python_version())
def _get_api_key_header_val(self, api_key):
"""
Check the type of the passed api_key and return the correct header value
for the API Key authentication
:arg api_key, either a tuple or a base64 encoded string
"""
if isinstance(api_key, (tuple, list)):
s = "{0}:{1}".format(api_key[0], api_key[1]).encode("utf-8")
return "ApiKey " + binascii.b2a_base64(s).rstrip(b"\r\n").decode("utf-8")
return "ApiKey " + api_key
-3
View File
@@ -61,8 +61,6 @@ class Connection(object):
timeout: Optional[Union[float, int]] = ...,
headers: Optional[Mapping[str, str]] = ...,
http_compress: Optional[bool] = ...,
cloud_id: Optional[str] = ...,
api_key: Optional[Union[Tuple[str, str], List[str], str]] = ...,
opaque_id: Optional[str] = ...,
**kwargs: Any
) -> None: ...
@@ -116,4 +114,3 @@ class Connection(object):
self, status_code: int, raw_data: str, content_type: Optional[str]
) -> NoReturn: ...
def _get_default_user_agent(self) -> str: ...
def _get_api_key_header_val(self, api_key: Any) -> str: ...
-7
View File
@@ -61,9 +61,6 @@ class RequestsHttpConnection(Connection):
separate cert and key files (client_cert will contain only the cert)
:arg headers: any custom http headers to be add to requests
:arg http_compress: Use gzip compression
:arg cloud_id: The Cloud ID from ElasticCloud. Convenient way to connect to cloud instances.
Other host connection params will be ignored.
:arg api_key: optional API Key authentication as either base64 encoded string or a tuple.
:arg opaque_id: Send this value in the 'X-Opaque-Id' HTTP header
For tracing all requests made by this transport.
"""
@@ -81,8 +78,6 @@ class RequestsHttpConnection(Connection):
client_key=None,
headers=None,
http_compress=None,
cloud_id=None,
api_key=None,
opaque_id=None,
**kwargs
):
@@ -102,8 +97,6 @@ class RequestsHttpConnection(Connection):
use_ssl=use_ssl,
headers=headers,
http_compress=http_compress,
cloud_id=cloud_id,
api_key=api_key,
opaque_id=opaque_id,
**kwargs
)
@@ -45,8 +45,6 @@ class RequestsHttpConnection(Connection):
client_key: Optional[Any] = ...,
headers: Optional[Mapping[str, str]] = ...,
http_compress: Optional[bool] = ...,
cloud_id: Optional[str] = ...,
api_key: Optional[Any] = ...,
opaque_id: Optional[str] = ...,
**kwargs: Any
) -> None: ...
-7
View File
@@ -100,9 +100,6 @@ class Urllib3HttpConnection(Connection):
information.
:arg headers: any custom http headers to be add to requests
:arg http_compress: Use gzip compression
:arg cloud_id: The Cloud ID from ElasticCloud. Convenient way to connect to cloud instances.
Other host connection params will be ignored.
:arg api_key: optional API Key authentication as either base64 encoded string or a tuple.
:arg opaque_id: Send this value in the 'X-Opaque-Id' HTTP header
For tracing all requests made by this transport.
"""
@@ -125,8 +122,6 @@ class Urllib3HttpConnection(Connection):
headers=None,
ssl_context=None,
http_compress=None,
cloud_id=None,
api_key=None,
opaque_id=None,
**kwargs
):
@@ -139,8 +134,6 @@ class Urllib3HttpConnection(Connection):
use_ssl=use_ssl,
headers=headers,
http_compress=http_compress,
cloud_id=cloud_id,
api_key=api_key,
opaque_id=opaque_id,
**kwargs
)
-2
View File
@@ -59,8 +59,6 @@ class Urllib3HttpConnection(Connection):
headers: Optional[Mapping[str, str]] = ...,
ssl_context: Optional[Any] = ...,
http_compress: Optional[bool] = ...,
cloud_id: Optional[str] = ...,
api_key: Optional[Any] = ...,
opaque_id: Optional[str] = ...,
**kwargs: Any
) -> None: ...
-5
View File
@@ -166,11 +166,6 @@ class Transport(object):
else:
self.seed_connections = []
# Don't enable sniffing on Cloud instances.
if kwargs.get("cloud_id", False):
sniff_on_start = False
sniff_on_connection_fail = False
# sniffing data
self.sniffer_timeout = sniffer_timeout
self.sniff_on_start = sniff_on_start