|
13 | 13 | CreateAppConfigAllowListInput, |
14 | 14 | PurgeAppConfigAllowListInput, |
15 | 15 | SearchAppConfigAllowListInput, |
| 16 | + UpdateAppConfigAllowListInput, |
16 | 17 | ) |
17 | 18 | from ai.backend.common.dto.manager.v2.app_config_allow_list.response import ( |
18 | 19 | AppConfigAllowListNode, |
19 | 20 | CreateAppConfigAllowListPayload, |
20 | 21 | PurgeAppConfigAllowListPayload, |
21 | 22 | SearchAppConfigAllowListPayload, |
| 23 | + UpdateAppConfigAllowListPayload, |
22 | 24 | ) |
23 | 25 | from ai.backend.common.dto.manager.v2.app_config_allow_list.types import ( |
24 | 26 | AppConfigAllowListOrderField, |
|
40 | 42 | from ai.backend.manager.repositories.app_config_allow_list.creators import ( |
41 | 43 | AppConfigAllowListCreatorSpec, |
42 | 44 | ) |
| 45 | +from ai.backend.manager.repositories.app_config_allow_list.updaters import ( |
| 46 | + AppConfigAllowListUpdaterSpec, |
| 47 | +) |
43 | 48 | from ai.backend.manager.repositories.base import ( |
44 | 49 | Purger, |
| 50 | + Updater, |
45 | 51 | combine_conditions_or, |
46 | 52 | negate_conditions, |
47 | 53 | ) |
|
58 | 64 | from ai.backend.manager.services.app_config_allow_list.actions.search import ( |
59 | 65 | SearchAppConfigAllowListAction, |
60 | 66 | ) |
| 67 | +from ai.backend.manager.services.app_config_allow_list.actions.update import ( |
| 68 | + UpdateAppConfigAllowListAction, |
| 69 | +) |
| 70 | +from ai.backend.manager.types import OptionalState |
61 | 71 |
|
62 | 72 |
|
63 | 73 | @lru_cache(maxsize=1) |
@@ -144,6 +154,26 @@ async def admin_search( |
144 | 154 | has_previous_page=action_result.has_previous_page, |
145 | 155 | ) |
146 | 156 |
|
| 157 | + async def admin_update( |
| 158 | + self, input: UpdateAppConfigAllowListInput |
| 159 | + ) -> UpdateAppConfigAllowListPayload: |
| 160 | + updater = Updater( |
| 161 | + spec=AppConfigAllowListUpdaterSpec( |
| 162 | + rank=( |
| 163 | + OptionalState.update(input.rank) |
| 164 | + if input.rank is not None |
| 165 | + else OptionalState.nop() |
| 166 | + ), |
| 167 | + ), |
| 168 | + pk_value=AppConfigAllowListID(input.id), |
| 169 | + ) |
| 170 | + action_result = await self._processors.app_config_allow_list.update.wait_for_complete( |
| 171 | + UpdateAppConfigAllowListAction(updater=updater) |
| 172 | + ) |
| 173 | + return UpdateAppConfigAllowListPayload( |
| 174 | + app_config_allow_list=self._data_to_node(action_result.allow_list), |
| 175 | + ) |
| 176 | + |
147 | 177 | async def admin_purge( |
148 | 178 | self, input: PurgeAppConfigAllowListInput |
149 | 179 | ) -> PurgeAppConfigAllowListPayload: |
|
0 commit comments