2424 ResourceNotFoundError ,
2525 handle_exception ,
2626)
27+ from owl .utils .mcp import MCP_TOOL_TAG
2728
2829router = APIRouter ()
2930
3031
31- @router .post ("/v2/secrets" )
32+ @router .post (
33+ "/v2/secrets" ,
34+ summary = "Create an organization secret." ,
35+ description = "Permissions: `organization.ADMIN`." ,
36+ tags = [MCP_TOOL_TAG , "organization.ADMIN" ],
37+ )
3238@handle_exception
3339async def create_secret (
3440 request : Request ,
@@ -80,9 +86,7 @@ async def create_secret(
8086 existing_projects = (await session .exec (statement )).all ()
8187 if len (existing_projects ) != len (body .allowed_projects ):
8288 non_exist_projects = set (body .allowed_projects ) - set (existing_projects )
83- raise BadInputError (
84- f"Non-existing projects are not allowed: '{ "', '" .join (non_exist_projects )} '."
85- )
89+ raise ResourceNotFoundError (f"Projects not found: { ', ' .join (non_exist_projects )} " )
8690
8791 # Create new secret
8892 secret = Secret (
@@ -103,8 +107,9 @@ async def create_secret(
103107
104108@router .get (
105109 "/v2/secrets/list" ,
106- summary = "List system-wide secrets." ,
110+ summary = "List organization secrets." ,
107111 description = "Permissions: `organization.MEMBER`." ,
112+ tags = [MCP_TOOL_TAG , "organization.MEMBER" ],
108113)
109114@handle_exception
110115async def list_secrets (
@@ -158,8 +163,9 @@ async def list_secrets(
158163
159164@router .get (
160165 "/v2/secrets" ,
161- summary = "Get a secret." ,
166+ summary = "Get an organization secret." ,
162167 description = "Permissions: `organization.MEMBER`." ,
168+ tags = [MCP_TOOL_TAG , "organization.MEMBER" ],
163169)
164170@handle_exception
165171async def get_secret (
@@ -195,11 +201,15 @@ async def get_secret(
195201 secret = await session .get (Secret , (organization_id , normalized_name ))
196202 if secret is None :
197203 raise ResourceNotFoundError (f'Secret "{ normalized_name } " is not found.' )
198-
199204 return secret .to_read_masked ()
200205
201206
202- @router .patch ("/v2/secrets" )
207+ @router .patch (
208+ "/v2/secrets" ,
209+ summary = "Update an organization secret." ,
210+ description = "Permissions: `organization.ADMIN`." ,
211+ tags = [MCP_TOOL_TAG , "organization.ADMIN" ],
212+ )
203213@handle_exception
204214async def update_secret (
205215 request : Request ,
@@ -256,9 +266,7 @@ async def update_secret(
256266 existing_projects = (await session .exec (statement )).all ()
257267 if len (existing_projects ) != len (body .allowed_projects ):
258268 non_exist_projects = set (body .allowed_projects ) - set (existing_projects )
259- raise BadInputError (
260- f"Non-existing projects are not allowed: '{ "', '" .join (non_exist_projects )} '."
261- )
269+ raise ResourceNotFoundError (f"Projects not found: { ', ' .join (non_exist_projects )} " )
262270 secret , updates = await Secret .update (
263271 session , (organization_id , normalized_name ), body , name = "Secret"
264272 )
@@ -272,8 +280,9 @@ async def update_secret(
272280
273281@router .delete (
274282 "/v2/secrets" ,
275- summary = "Delete a secret." ,
283+ summary = "Delete an organization secret." ,
276284 description = "Permissions: `organization.ADMIN`." ,
285+ tags = [MCP_TOOL_TAG , "organization.ADMIN" ],
277286)
278287@handle_exception
279288async def delete_secret (
0 commit comments