3434)
3535from public_api .views .timeseries_viewset import APITimeSeriesViewSet
3636
37+ TIMESERIES_PREFIX = "timeseries/"
38+ SEARCH_PREFIX = "search/"
39+
3740
3841def 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+ ]
0 commit comments