Skip to content

Commit

Permalink
Add serverless override
Browse files Browse the repository at this point in the history
Signed-off-by: Simeon Widdis <[email protected]>
  • Loading branch information
Swiddis committed Nov 7, 2024
1 parent d7f4041 commit 70c40bb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/opensearch_sql_cli/opensearch_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@ def __init__(
http_auth=None,
use_aws_authentication=False,
query_language="sql",
response_timeout=10
response_timeout=10,
serverless_override=None,
):
"""Initialize an OpenSearchConnection instance.
Set up client and get indices list.
:param endpoint: an url in the format of "http://localhost:9200"
:param http_auth: a tuple in the format of (username, password)
:param serverless_override: by default we analyze the provided endpoint string to determine
whether the endpoint is serverless or not. This option allows overriding that logic and
forcing the connection to be serverless (true) or not (false).
"""
self.client = None
self.ssl_context = None
Expand All @@ -47,7 +51,10 @@ def __init__(
self.use_aws_authentication = use_aws_authentication
self.query_language = query_language
self.response_timeout = response_timeout
self.is_aws_serverless = self.use_aws_authentication and ".aoss.amazonaws.com" in self.endpoint
if serverless_override is not None:
self.is_aws_serverless = serverless_override
else:
self.is_aws_serverless = self.use_aws_authentication and ".aoss.amazonaws.com" in self.endpoint

def get_indices(self):
if self.client:
Expand Down

0 comments on commit 70c40bb

Please sign in to comment.