Skip to content

Commit 5f72a3a

Browse files
committed
fix url
1 parent 5fb0027 commit 5f72a3a

3 files changed

Lines changed: 33 additions & 9 deletions

File tree

metrics/api/urls_construction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def construct_cms_admin_urlpatterns(
9898
]
9999

100100

101-
DEFAULT_PUBLIC_API_PREFIX = "api/public/timeseries/"
101+
DEFAULT_PUBLIC_API_PREFIX = "api/public/"
102102

103103

104104
def construct_public_api_urlpatterns(

public_api/urls.py

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
)
3535
from public_api.views.timeseries_viewset import APITimeSeriesViewSet
3636

37+
TIMESERIES_PREFIX = "timeseries/"
38+
SEARCH_PREFIX = "search/"
39+
3740

3841
def construct_url_patterns_for_public_api(
3942
*,
@@ -49,8 +52,12 @@ def construct_url_patterns_for_public_api(
4952
set of versioned URLS.
5053
"""
5154
urls = []
52-
urls.extend(_construct_version_one_urls(prefix=prefix))
53-
urls.extend(_construct_version_two_urls(prefix=prefix))
55+
# Timeseries API
56+
urls.extend(_construct_version_one_urls(prefix=prefix + TIMESERIES_PREFIX))
57+
urls.extend(_construct_version_two_urls(prefix=prefix + TIMESERIES_PREFIX))
58+
59+
# Search API
60+
urls.extend(_construct_search_urls(prefix=prefix + SEARCH_PREFIX))
5461

5562
if MetricsPublicAPIInterface.is_auth_enabled():
5663
urls.append(
@@ -160,11 +167,6 @@ def _construct_version_two_urls(
160167
PublicAPIRootViewV2.as_view(),
161168
name="public-api-v2",
162169
),
163-
path(
164-
f"{prefix}v2/search",
165-
SearchView.as_view(),
166-
name="search",
167-
),
168170
path(
169171
f"{prefix}v2/themes/",
170172
ThemeListViewV2.as_view(),
@@ -228,3 +230,25 @@ def _construct_version_two_urls(
228230
name="timeseries-list-v2",
229231
),
230232
]
233+
234+
235+
def _construct_search_urls(
236+
*,
237+
prefix: str,
238+
) -> list[resolvers.URLResolver]:
239+
"""Returns a list of URLResolvers for the public search API
240+
241+
Args:
242+
prefix: The prefix to add to the start of the url paths
243+
244+
Returns:
245+
List of `URLResolver` objects each representing a
246+
set of versioned URLS.
247+
"""
248+
return [
249+
path(
250+
f"{prefix}v1",
251+
SearchView.as_view(),
252+
name="search",
253+
),
254+
]

tests/integration/public_api/v2/views/test_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class TestSearchAPIView:
1818

1919
@property
2020
def path(self) -> str:
21-
return "/api/public/timeseries/v2/search"
21+
return "/api/public/search/v1"
2222

2323
@property
2424
def target_domain(self) -> str:

0 commit comments

Comments
 (0)