Skip to content

Commit 481b114

Browse files
committed
refactor(BA-5844): switch REST v2 Policy surface to id-keyed routes
Track BA-5814 / BA-5815 DTO refactor: • GET /v2/app-config-policies/{config_name} → GET /v2/app-config-policies/{policy_id} • Replace AppConfigPolicyConfigNamePathParam with AppConfigPolicyIdPathParam (policy_id: UUID). • Update bulk-purge handler docstring (purge keyed on row id).
1 parent 66c4b52 commit 481b114

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

changes/11312.feature.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Add `AppConfigPolicy` REST v2 surface (`POST /v2/app-config-policies/search`, `GET /v2/app-config-policies/{config_name}`, admin `bulk-create` / `bulk-update` / `bulk-purge`) — pairs with the GraphQL surface from BA-5815.
1+
Add `AppConfigPolicy` REST v2 surface (`POST /v2/app-config-policies/search`, `GET /v2/app-config-policies/{policy_id}`, admin `bulk-create` / `bulk-update` / `bulk-purge`) — pairs with the GraphQL surface from BA-5815.

src/ai/backend/manager/api/rest/v2/app_config_policy/handler.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
SearchAppConfigPoliciesInput,
2020
)
2121
from ai.backend.logging import BraceStyleAdapter
22-
from ai.backend.manager.api.rest.v2.path_params import AppConfigPolicyConfigNamePathParam
22+
from ai.backend.manager.api.rest.v2.path_params import AppConfigPolicyIdPathParam
2323

2424
if TYPE_CHECKING:
2525
from ai.backend.manager.api.adapters.app_config_policy import AppConfigPolicyAdapter
@@ -37,10 +37,10 @@ def __init__(self, *, adapter: AppConfigPolicyAdapter) -> None:
3737

3838
async def get(
3939
self,
40-
path: PathParam[AppConfigPolicyConfigNamePathParam],
40+
path: PathParam[AppConfigPolicyIdPathParam],
4141
) -> APIResponse:
42-
"""Read a single policy by `config_name` (any authenticated user)."""
43-
result = await self._adapter.get(path.parsed.config_name)
42+
"""Read a single policy by row id (any authenticated user)."""
43+
result = await self._adapter.get(path.parsed.policy_id)
4444
return APIResponse.build(status_code=HTTPStatus.OK, response_model=result)
4545

4646
async def search(
@@ -73,6 +73,6 @@ async def admin_bulk_purge(
7373
self,
7474
body: BodyParam[AdminBulkPurgeAppConfigPoliciesInput],
7575
) -> APIResponse:
76-
"""Hard-delete (admin only); referenced `config_name`s fail per-item."""
76+
"""Hard-delete by row id (admin only); rows still referenced by fragments fail per-item."""
7777
result = await self._adapter.admin_bulk_purge(body.parsed)
7878
return APIResponse.build(status_code=HTTPStatus.OK, response_model=result)

src/ai/backend/manager/api/rest/v2/app_config_policy/registry.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ def register_v2_app_config_policy_routes(
1919
) -> RouteRegistry:
2020
"""Register all v2 app-config policy routes.
2121
22-
Reads (`GET /{config_name}`, `POST /search`) are available to any
22+
Reads (`GET /{policy_id}`, `POST /search`) are available to any
2323
authenticated user. Writes are bulk-only and admin-only —
2424
`/bulk-create`, `/bulk-update`, `/bulk-purge`.
2525
"""
2626
reg = RouteRegistry.create("app-config-policies", route_deps.cors_options)
2727

2828
# Reads
2929
reg.add("POST", "/search", handler.search, middlewares=[auth_required])
30-
reg.add("GET", "/{config_name}", handler.get, middlewares=[auth_required])
30+
reg.add("GET", "/{policy_id}", handler.get, middlewares=[auth_required])
3131
# Admin bulk writes
3232
reg.add("POST", "/bulk-create", handler.admin_bulk_create, middlewares=[superadmin_required])
3333
reg.add("POST", "/bulk-update", handler.admin_bulk_update, middlewares=[superadmin_required])

src/ai/backend/manager/api/rest/v2/path_params.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
from ai.backend.common.api_handlers import BaseRequestModel
1010

1111

12-
class AppConfigPolicyConfigNamePathParam(BaseRequestModel):
13-
config_name: str = Field(description="App-config policy `config_name`")
12+
class AppConfigPolicyIdPathParam(BaseRequestModel):
13+
policy_id: UUID = Field(description="App-config policy row UUID")
1414

1515

1616
class DomainNamePathParam(BaseRequestModel):

0 commit comments

Comments
 (0)