1414from models_library .api_schemas_webserver .catalog import (
1515 CatalogServiceGet ,
1616 CatalogServiceUpdate ,
17- ServiceInputKey ,
18- ServiceOutputKey ,
1917)
2018from models_library .api_schemas_webserver .resource_usage import PricingPlanGet
21- from models_library .rest_pagination import Page , PageQueryParameters
19+ from models_library .rest_pagination import Page
2220from models_library .rest_pagination_utils import paginate_data
23- from models_library .services import ServiceKey , ServiceVersion
2421from models_library .services_resources import (
2522 ServiceResourcesDict ,
2623 ServiceResourcesDictHelpers ,
2724)
28- from pydantic import BaseModel , Field
2925from servicelib .aiohttp .requests_validation import (
3026 parse_request_body_as ,
3127 parse_request_path_parameters_as ,
4541)
4642from ._controller_rest_schemas import (
4743 CatalogRequestContext ,
44+ FromServiceOutputQueryParams ,
4845 ListServiceParams ,
46+ ServiceInputsPathParams ,
47+ ServiceOutputsPathParams ,
4948 ServicePathParams ,
5049 ServiceTagPathParams ,
50+ ToServiceInputsQueryParams ,
5151)
5252
5353_logger = logging .getLogger (__name__ )
@@ -76,9 +76,8 @@ async def list_services_latest(request: Request):
7676 user_id = request_ctx .user_id ,
7777 product_name = request_ctx .product_name ,
7878 unit_registry = request_ctx .unit_registry ,
79- page_params = PageQueryParameters .model_construct (
80- offset = query_params .offset , limit = query_params .limit
81- ),
79+ offset = query_params .offset ,
80+ limit = query_params .limit ,
8281 )
8382
8483 assert page_meta .limit == query_params .limit # nosec
@@ -174,10 +173,6 @@ async def list_service_inputs(request: Request):
174173 )
175174
176175
177- class _ServiceInputsPathParams (ServicePathParams ):
178- input_key : ServiceInputKey
179-
180-
181176@routes .get (
182177 f"{ VTAG } /catalog/services/{{service_key}}/{{service_version}}/inputs/{{input_key}}" ,
183178 name = "get_service_input" ,
@@ -186,7 +181,7 @@ class _ServiceInputsPathParams(ServicePathParams):
186181@permission_required ("services.catalog.*" )
187182async def get_service_input (request : Request ):
188183 ctx = CatalogRequestContext .create (request )
189- path_params = parse_request_path_parameters_as (_ServiceInputsPathParams , request )
184+ path_params = parse_request_path_parameters_as (ServiceInputsPathParams , request )
190185
191186 # Evaluate and return validated model
192187 response_model = await _service .get_service_input (
@@ -202,12 +197,6 @@ async def get_service_input(request: Request):
202197 )
203198
204199
205- class _FromServiceOutputParams (BaseModel ):
206- from_service_key : ServiceKey = Field (..., alias = "fromService" )
207- from_service_version : ServiceVersion = Field (..., alias = "fromVersion" )
208- from_output_key : ServiceOutputKey = Field (..., alias = "fromOutput" )
209-
210-
211200@routes .get (
212201 f"{ VTAG } /catalog/services/{{service_key}}/{{service_version}}/inputs:match" ,
213202 name = "get_compatible_inputs_given_source_output" ,
@@ -217,8 +206,8 @@ class _FromServiceOutputParams(BaseModel):
217206async def get_compatible_inputs_given_source_output (request : Request ):
218207 ctx = CatalogRequestContext .create (request )
219208 path_params = parse_request_path_parameters_as (ServicePathParams , request )
220- query_params : _FromServiceOutputParams = parse_request_query_parameters_as (
221- _FromServiceOutputParams , request
209+ query_params : FromServiceOutputQueryParams = parse_request_query_parameters_as (
210+ FromServiceOutputQueryParams , request
222211 )
223212
224213 # Evaluate and return validated model
@@ -257,10 +246,6 @@ async def list_service_outputs(request: Request):
257246 )
258247
259248
260- class _ServiceOutputsPathParams (ServicePathParams ):
261- output_key : ServiceOutputKey
262-
263-
264249@routes .get (
265250 f"{ VTAG } /catalog/services/{{service_key}}/{{service_version}}/outputs/{{output_key}}" ,
266251 name = "get_service_output" ,
@@ -269,7 +254,7 @@ class _ServiceOutputsPathParams(ServicePathParams):
269254@permission_required ("services.catalog.*" )
270255async def get_service_output (request : Request ):
271256 ctx = CatalogRequestContext .create (request )
272- path_params = parse_request_path_parameters_as (_ServiceOutputsPathParams , request )
257+ path_params = parse_request_path_parameters_as (ServiceOutputsPathParams , request )
273258
274259 # Evaluate and return validated model
275260 response_model = await _service .get_service_output (
@@ -285,12 +270,6 @@ async def get_service_output(request: Request):
285270 )
286271
287272
288- class _ToServiceInputsParams (BaseModel ):
289- to_service_key : ServiceKey = Field (..., alias = "toService" )
290- to_service_version : ServiceVersion = Field (..., alias = "toVersion" )
291- to_input_key : ServiceInputKey = Field (..., alias = "toInput" )
292-
293-
294273@routes .get (
295274 f"{ VTAG } /catalog/services/{{service_key}}/{{service_version}}/outputs:match" ,
296275 name = "get_compatible_outputs_given_target_input" ,
@@ -305,8 +284,8 @@ async def get_compatible_outputs_given_target_input(request: Request):
305284 """
306285 ctx = CatalogRequestContext .create (request )
307286 path_params = parse_request_path_parameters_as (ServicePathParams , request )
308- query_params : _ToServiceInputsParams = parse_request_query_parameters_as (
309- _ToServiceInputsParams , request
287+ query_params : ToServiceInputsQueryParams = parse_request_query_parameters_as (
288+ ToServiceInputsQueryParams , request
310289 )
311290
312291 data = await _service .get_compatible_outputs_given_target_input (
0 commit comments