Skip to content
Snippets Groups Projects
Commit eed02a99 authored by !! Julian Keck (old Account; do not use) !!'s avatar !! Julian Keck (old Account; do not use) !! :ghost:
Browse files

UPD use enum for patch request action types

parent 4fb0683e
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@ from starlette import status
from api import db, get_conn
from model.mail_requests import APIPatchRequestAction, PatchRequestFormRequest, InformalPatchRequestFormRequest, \
PatchRequestAction
PatchRequestAction, PatchActionType
from model.settings import settings
from model.wapi.cntl import APIToken, Mgr
from model.wapi.nd import Port, Module, Room, Bldg, Site
......@@ -131,7 +131,7 @@ def validate_patch_request_actions(conn, user, actions: list[APIPatchRequestActi
{'idx': 'bcd_list', 'name': 'nd.bcd.list', 'old': {'name': action.bcd_name}},
], user=user.login_name)
internal_action.bcd = Port(**bcd_result['bcd_list'][0])
elif action.action.lower() == 'patch':
elif action.action == PatchActionType.PATCH:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail='BCD is required for patch action'
......
from typing import Optional
from pydantic import BaseModel, Field
from enum import Enum
from model.wapi.nd import BCD, Bldg, Module, Room, Port, Site
class PatchActionType(Enum):
PATCH = 'patch'
UNPATCH = 'unpatch'
CHANGE_INSERT = 'change_insert'
class APIPatchRequestAction(BaseModel):
action: str = Field()
action: PatchActionType = Field()
bcd_name: Optional[str] = Field(default=None)
bcd_tagged: Optional[bool] = Field(default=False)
building_gpk: str = Field()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment