Skip to content

Commit cb7c873

Browse files
remove errors
1 parent 4f09be2 commit cb7c873

File tree

1 file changed

+17
-31
lines changed
  • services/web/server/src/simcore_service_webserver/api_keys

1 file changed

+17
-31
lines changed

services/web/server/src/simcore_service_webserver/api_keys/_rest.py

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
parse_request_body_as,
1111
parse_request_path_parameters_as,
1212
)
13-
from servicelib.mimetype_constants import MIMETYPE_APPLICATION_JSON
14-
from simcore_postgres_database.errors import DatabaseError
1513
from simcore_service_webserver.api_keys._exceptions_handlers import (
1614
handle_plugin_requests_exceptions,
1715
)
@@ -41,22 +39,17 @@ class ApiKeysPathParams(StrictRequestParameters):
4139
async def create_api_key(request: web.Request):
4240
req_ctx = RequestContext.model_validate(request)
4341
new_api_key = await parse_request_body_as(ApiKeyCreate, request)
44-
try:
45-
created_api_key: ApiKey = await _api.create_api_key(
46-
request.app,
47-
display_name=new_api_key.display_name,
48-
expiration=new_api_key.expiration,
49-
user_id=req_ctx.user_id,
50-
product_name=req_ctx.product_name,
51-
)
52-
53-
api_key = ApiKeyGet.model_validate(created_api_key)
54-
# api_key.api_base_url = TODO: https://github.com/ITISFoundation/osparc-simcore/issues/6340
55-
except DatabaseError as err:
56-
raise web.HTTPBadRequest(
57-
reason="Invalid API key name: already exists",
58-
content_type=MIMETYPE_APPLICATION_JSON,
59-
) from err
42+
43+
created_api_key: ApiKey = await _api.create_api_key(
44+
request.app,
45+
display_name=new_api_key.display_name,
46+
expiration=new_api_key.expiration,
47+
user_id=req_ctx.user_id,
48+
product_name=req_ctx.product_name,
49+
)
50+
51+
api_key = ApiKeyGet.model_validate(created_api_key)
52+
# api_key.api_base_url = TODO: https://github.com/ITISFoundation/osparc-simcore/issues/6340 # @pcrespov
6053

6154
return envelope_json_response(api_key)
6255

@@ -101,18 +94,11 @@ async def delete_api_key(request: web.Request):
10194
req_ctx = RequestContext.model_validate(request)
10295
path_params = parse_request_path_parameters_as(ApiKeysPathParams, request)
10396

104-
try:
105-
await _api.delete_api_key(
106-
request.app,
107-
api_key_id=path_params.api_key_id,
108-
user_id=req_ctx.user_id,
109-
product_name=req_ctx.product_name,
110-
)
111-
except DatabaseError as err:
112-
_logger.warning(
113-
"Failed to delete API key with ID: %s. Ignoring error",
114-
path_params.api_key_id,
115-
exc_info=err,
116-
)
97+
await _api.delete_api_key(
98+
request.app,
99+
api_key_id=path_params.api_key_id,
100+
user_id=req_ctx.user_id,
101+
product_name=req_ctx.product_name,
102+
)
117103

118104
return web.json_response(status=status.HTTP_204_NO_CONTENT)

0 commit comments

Comments
 (0)