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 ,
3935from ..security .decorators import permission_required
4036from ..utils_aiohttp import envelope_json_response
4137from . import _catalog_rest_client_service , _service
42- from ._exceptions import (
38+ from ._controller_rest_exceptions import (
4339 DefaultPricingUnitForServiceNotFoundError ,
4440 handle_plugin_requests_exceptions ,
4541)
46- from .controller_rest_schemas import (
42+ from ._controller_rest_schemas import (
4743 CatalogRequestContext ,
44+ FromServiceOutputQueryParams ,
4845 ListServiceParams ,
46+ ServiceInputsPathParams ,
47+ ServiceOutputsPathParams ,
4948 ServicePathParams ,
49+ ServiceTagPathParams ,
50+ ToServiceInputsQueryParams ,
5051)
5152
5253_logger = logging .getLogger (__name__ )
@@ -75,9 +76,8 @@ async def list_services_latest(request: Request):
7576 user_id = request_ctx .user_id ,
7677 product_name = request_ctx .product_name ,
7778 unit_registry = request_ctx .unit_registry ,
78- page_params = PageQueryParameters .model_construct (
79- offset = query_params .offset , limit = query_params .limit
80- ),
79+ offset = query_params .offset ,
80+ limit = query_params .limit ,
8181 )
8282
8383 assert page_meta .limit == query_params .limit # nosec
@@ -173,10 +173,6 @@ async def list_service_inputs(request: Request):
173173 )
174174
175175
176- class _ServiceInputsPathParams (ServicePathParams ):
177- input_key : ServiceInputKey
178-
179-
180176@routes .get (
181177 f"{ VTAG } /catalog/services/{{service_key}}/{{service_version}}/inputs/{{input_key}}" ,
182178 name = "get_service_input" ,
@@ -185,7 +181,7 @@ class _ServiceInputsPathParams(ServicePathParams):
185181@permission_required ("services.catalog.*" )
186182async def get_service_input (request : Request ):
187183 ctx = CatalogRequestContext .create (request )
188- path_params = parse_request_path_parameters_as (_ServiceInputsPathParams , request )
184+ path_params = parse_request_path_parameters_as (ServiceInputsPathParams , request )
189185
190186 # Evaluate and return validated model
191187 response_model = await _service .get_service_input (
@@ -201,12 +197,6 @@ async def get_service_input(request: Request):
201197 )
202198
203199
204- class _FromServiceOutputParams (BaseModel ):
205- from_service_key : ServiceKey = Field (..., alias = "fromService" )
206- from_service_version : ServiceVersion = Field (..., alias = "fromVersion" )
207- from_output_key : ServiceOutputKey = Field (..., alias = "fromOutput" )
208-
209-
210200@routes .get (
211201 f"{ VTAG } /catalog/services/{{service_key}}/{{service_version}}/inputs:match" ,
212202 name = "get_compatible_inputs_given_source_output" ,
@@ -216,8 +206,8 @@ class _FromServiceOutputParams(BaseModel):
216206async def get_compatible_inputs_given_source_output (request : Request ):
217207 ctx = CatalogRequestContext .create (request )
218208 path_params = parse_request_path_parameters_as (ServicePathParams , request )
219- query_params : _FromServiceOutputParams = parse_request_query_parameters_as (
220- _FromServiceOutputParams , request
209+ query_params : FromServiceOutputQueryParams = parse_request_query_parameters_as (
210+ FromServiceOutputQueryParams , request
221211 )
222212
223213 # Evaluate and return validated model
@@ -256,10 +246,6 @@ async def list_service_outputs(request: Request):
256246 )
257247
258248
259- class _ServiceOutputsPathParams (ServicePathParams ):
260- output_key : ServiceOutputKey
261-
262-
263249@routes .get (
264250 f"{ VTAG } /catalog/services/{{service_key}}/{{service_version}}/outputs/{{output_key}}" ,
265251 name = "get_service_output" ,
@@ -268,7 +254,7 @@ class _ServiceOutputsPathParams(ServicePathParams):
268254@permission_required ("services.catalog.*" )
269255async def get_service_output (request : Request ):
270256 ctx = CatalogRequestContext .create (request )
271- path_params = parse_request_path_parameters_as (_ServiceOutputsPathParams , request )
257+ path_params = parse_request_path_parameters_as (ServiceOutputsPathParams , request )
272258
273259 # Evaluate and return validated model
274260 response_model = await _service .get_service_output (
@@ -284,12 +270,6 @@ async def get_service_output(request: Request):
284270 )
285271
286272
287- class _ToServiceInputsParams (BaseModel ):
288- to_service_key : ServiceKey = Field (..., alias = "toService" )
289- to_service_version : ServiceVersion = Field (..., alias = "toVersion" )
290- to_input_key : ServiceInputKey = Field (..., alias = "toInput" )
291-
292-
293273@routes .get (
294274 f"{ VTAG } /catalog/services/{{service_key}}/{{service_version}}/outputs:match" ,
295275 name = "get_compatible_outputs_given_target_input" ,
@@ -304,8 +284,8 @@ async def get_compatible_outputs_given_target_input(request: Request):
304284 """
305285 ctx = CatalogRequestContext .create (request )
306286 path_params = parse_request_path_parameters_as (ServicePathParams , request )
307- query_params : _ToServiceInputsParams = parse_request_query_parameters_as (
308- _ToServiceInputsParams , request
287+ query_params : ToServiceInputsQueryParams = parse_request_query_parameters_as (
288+ ToServiceInputsQueryParams , request
309289 )
310290
311291 data = await _service .get_compatible_outputs_given_target_input (
@@ -377,3 +357,43 @@ async def get_service_pricing_plan(request: Request):
377357 return envelope_json_response (
378358 PricingPlanGet .model_validate (pricing_plan .model_dump ())
379359 )
360+
361+
362+ @routes .get (
363+ f"/{ API_VTAG } /catalog/services/{{service_key}}/{{service_version}}/tags" ,
364+ name = "list_service_tags" ,
365+ )
366+ @login_required
367+ @permission_required ("service.tag.*" )
368+ async def list_service_tags (request : web .Request ):
369+ path_params = parse_request_path_parameters_as (ServicePathParams , request )
370+ assert path_params # nosec
371+ raise NotImplementedError
372+
373+
374+ @routes .post (
375+ f"/{ API_VTAG } /catalog/services/{{service_key}}/{{service_version}}/tags/{{tag_id}}:add" ,
376+ name = "add_service_tag" ,
377+ )
378+ @login_required
379+ @permission_required ("service.tag.*" )
380+ async def add_service_tag (request : web .Request ):
381+ path_params = parse_request_path_parameters_as (ServiceTagPathParams , request )
382+ assert path_params # nosec
383+
384+ # responds with parent's resource to get the current state (as with patch/update)
385+ raise NotImplementedError
386+
387+
388+ @routes .post (
389+ f"/{ API_VTAG } /catalog/services/{{service_key}}/{{service_version}}/tags/{{tag_id}}:remove" ,
390+ name = "remove_service_tag" ,
391+ )
392+ @login_required
393+ @permission_required ("service.tag.*" )
394+ async def remove_service_tag (request : web .Request ):
395+ path_params = parse_request_path_parameters_as (ServiceTagPathParams , request )
396+ assert path_params # nosec
397+
398+ # responds with parent's resource to get the current state (as with patch/update)
399+ raise NotImplementedError
0 commit comments