Skip to content

Remove deprecated url_prefix and use_ssl options #2797

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions elasticsearch/_sync/client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ def host_mapping_to_node_config(host: Mapping[str, Union[str, int]]) -> NodeConf
"host",
"port",
"path_prefix",
"url_prefix",
"use_ssl",
}
disallowed_keys = set(host.keys()).difference(allow_hosts_keys)
if disallowed_keys:
Expand All @@ -197,41 +195,6 @@ def host_mapping_to_node_config(host: Mapping[str, Union[str, int]]) -> NodeConf

options = dict(host)

# Handle the deprecated option 'use_ssl'
if "use_ssl" in options:
use_ssl = options.pop("use_ssl")
if not isinstance(use_ssl, bool):
raise TypeError("'use_ssl' must be of type 'bool'")

# Ensure the user isn't specifying scheme=http use_ssl=True or vice-versa
if "scheme" in options and (options["scheme"] == "https") != use_ssl:
raise ValueError(
f"Cannot specify conflicting options 'scheme={options['scheme']}' "
f"and 'use_ssl={use_ssl}'. Use 'scheme' only instead"
)

warnings.warn(
"The 'use_ssl' option is no longer needed as specifying a 'scheme' is now required",
category=DeprecationWarning,
stacklevel=warn_stacklevel(),
)
options.setdefault("scheme", "https" if use_ssl else "http")

# Handle the deprecated option 'url_prefix'
if "url_prefix" in options:
if "path_prefix" in options:
raise ValueError(
"Cannot specify conflicting options 'url_prefix' and "
"'path_prefix'. Use 'path_prefix' only instead"
)

warnings.warn(
"The 'url_prefix' option is deprecated in favor of 'path_prefix'",
category=DeprecationWarning,
stacklevel=warn_stacklevel(),
)
options["path_prefix"] = options.pop("url_prefix")

return NodeConfig(**options) # type: ignore[arg-type]


Expand Down