Thanks to visit codestin.com
Credit goes to github.com

Skip to content

remove deprecated HTTP endpoints / routes #9533

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 2 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
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
11 changes: 0 additions & 11 deletions localstack/services/cloudwatch/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
)
from localstack.aws.connect import connect_to
from localstack.constants import DEFAULT_AWS_ACCOUNT_ID
from localstack.deprecations import deprecated_endpoint
from localstack.http import Request
from localstack.services import moto
from localstack.services.cloudwatch.alarm_scheduler import AlarmScheduler
Expand Down Expand Up @@ -232,16 +231,6 @@ def __init__(self):

def on_after_init(self):
ROUTER.add(PATH_GET_RAW_METRICS, self.get_raw_metrics)
# TODO remove with 2.0
ROUTER.add(
DEPRECATED_PATH_GET_RAW_METRICS,
deprecated_endpoint(
self.get_raw_metrics,
previous_path=DEPRECATED_PATH_GET_RAW_METRICS,
deprecation_version="1.3.0",
new_path=PATH_GET_RAW_METRICS,
),
)
self.start_alarm_scheduler()

def on_before_state_reset(self):
Expand Down
5 changes: 1 addition & 4 deletions localstack/services/infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from localstack.services import motoserver
from localstack.services.generic_proxy import ProxyListener, start_proxy_server
from localstack.services.plugins import SERVICE_PLUGINS, ServiceDisabled, wait_for_infra_shutdown
from localstack.utils import config_listener, files, objects
from localstack.utils import files, objects
from localstack.utils.analytics import usage
from localstack.utils.aws.request_context import patch_moto_request_handling
from localstack.utils.bootstrap import is_api_enabled, log_duration, setup_logging
Expand Down Expand Up @@ -66,9 +66,6 @@
# can be set
EXIT_CODE: objects.Value[int] = objects.Value(0)

# Start config update backdoor
config_listener.start_listener()


# ---------------
# HELPER METHODS
Expand Down
13 changes: 0 additions & 13 deletions localstack/services/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,7 @@ def add_default_routes(self):
from localstack.services.plugins import SERVICE_PLUGINS

health_resource = HealthResource(SERVICE_PLUGINS)
# special route for legacy support (before `/_localstack` was introduced)
self.add(
Resource(
"/health",
DeprecatedResource(
health_resource,
previous_path="/health",
deprecation_version="1.3.0",
new_path="/_localstack/health",
),
),
)
self.add(Resource("/_localstack/health", health_resource))

self.add(Resource("/_localstack/info", InfoResource()))
self.add(Resource("/_localstack/plugins", PluginsResource()))
self.add(Resource("/_localstack/init", InitScriptsResource()))
Expand Down
17 changes: 1 addition & 16 deletions localstack/services/ses/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
from localstack.aws.connect import connect_to
from localstack.constants import TEST_AWS_SECRET_ACCESS_KEY
from localstack.http import Resource, Response
from localstack.services.internal import DeprecatedResource, get_internal_apis
from localstack.services.moto import call_moto
from localstack.services.plugins import ServiceLifecycleHook
from localstack.services.ses.models import SentEmail, SentEmailBody
Expand Down Expand Up @@ -165,23 +164,9 @@ def register_ses_api_resource():
global _EMAILS_ENDPOINT_REGISTERED

if not _EMAILS_ENDPOINT_REGISTERED:
ses_service_api_resource = SesServiceApiResource()
get_internal_apis().add(
Resource(
"/_localstack/ses",
DeprecatedResource(
ses_service_api_resource,
previous_path="/_localstack/ses",
deprecation_version="1.4.0",
new_path="/_aws/ses",
),
)
)

from localstack.services.edge import ROUTER

ROUTER.add(Resource(EMAILS_ENDPOINT, ses_service_api_resource))

ROUTER.add(Resource(EMAILS_ENDPOINT, SesServiceApiResource()))
_EMAILS_ENDPOINT_REGISTERED = True


Expand Down
38 changes: 1 addition & 37 deletions localstack/utils/config_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

from requests.models import Response

from localstack import config, constants
from localstack.deprecations import deprecated_endpoint
from localstack.services.generic_proxy import ProxyListener
from localstack import config

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -42,37 +40,3 @@ def _update_config_variable_handler(data):
result = {"variable": variable, "value": value}
response._content = json.dumps(result)
return response


class ConfigUpdateProxyListener(ProxyListener):
"""Default proxy listener that intercepts requests to retrieve or update config variables."""

def __init__(self):
self._handler = deprecated_endpoint(
endpoint=_update_config_variable_handler,
previous_path=constants.CONFIG_UPDATE_PATH,
deprecation_version="1.4.0",
new_path="/_localstack/config",
)

def forward_request(self, method, path, data, headers):
if path != constants.CONFIG_UPDATE_PATH or method != "POST":
return True

return self._handler(data)


CONFIG_UPDATE_LISTENER = ConfigUpdateProxyListener()


def start_listener():
if config.ENABLE_CONFIG_UPDATES:
ProxyListener.DEFAULT_LISTENERS.append(CONFIG_UPDATE_LISTENER)


def remove_listener():
if not config.ENABLE_CONFIG_UPDATES:
try:
ProxyListener.DEFAULT_LISTENERS.remove(CONFIG_UPDATE_LISTENER)
except ValueError:
pass
2 changes: 1 addition & 1 deletion tests/aws/services/ses/test_ses.py
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ def test_send_templated_email_can_retrospect(self, create_template, aws_client):
assert '{"A key": "A value"}' == contents["TemplateData"]
assert ["[email protected]"] == contents["Destination"]["ToAddresses"]

api_contents = requests.get("http://localhost:4566/_localstack/ses").json()
api_contents = requests.get("http://localhost:4566/_aws/ses").json()
api_contents = {msg["Id"]: msg for msg in api_contents["messages"]}
assert message_id in api_contents
assert api_contents[message_id] == contents
Expand Down
15 changes: 0 additions & 15 deletions tests/integration/test_config_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import requests

from localstack import config
from localstack.constants import CONFIG_UPDATE_PATH
from localstack.http import Resource
from localstack.services.internal import ConfigResource, get_internal_apis
from localstack.utils import config_listener
Expand All @@ -15,12 +14,9 @@ def config_endpoint(monkeypatch):

router = get_internal_apis()
monkeypatch.setattr(config, "ENABLE_CONFIG_UPDATES", True)
# will listen on /?_config_
config_listener.start_listener()
# will listen on /_localstack/config
rules = router.add(Resource("/_localstack/config", ConfigResource()))
yield
config_listener.remove_listener()
router.remove(rules)


Expand All @@ -35,17 +31,6 @@ def custom_listener(config_key, config_value):
config.FOO = None
config_listener.CONFIG_LISTENERS.append(custom_listener)

# test the ProxyListener
body = {"variable": "FOO", "value": "BAR"}
url = f"{config.get_edge_url()}{CONFIG_UPDATE_PATH}"
response = requests.post(url, json=body)
assert 200 == response.status_code
response_body = response.json()
assert body == response_body
assert body["value"] == config.FOO
assert body["variable"] == key
assert body["value"] == value

# test the Route
body = {"variable": "FOO", "value": "BAZ"}
config_listener.CONFIG_LISTENERS.append(custom_listener)
Expand Down
6 changes: 0 additions & 6 deletions tests/unit/services/test_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ def test_get(self):
class TestLocalstackResourceHandlerIntegration:
def test_health(self, monkeypatch):
with proxy_server(LocalstackResourceHandler()) as url:
# legacy endpoint
response = requests.get(f"{url}/health")
assert response.ok
assert "services" in response.json()

# new internal endpoint
response = requests.get(f"{url}/_localstack/health")
assert response.ok
assert "services" in response.json()
Expand Down