api: implement operating locks
This commit is contained in:
parent
b7aeeab762
commit
60c4770280
3 changed files with 45 additions and 12 deletions
|
|
@ -13,7 +13,7 @@ class HttpProblemType(Enum):
|
|||
"""
|
||||
|
||||
UNAUTHORIZED = "type:noc@hamburg.ccc.de,2026:UNAUTHORIZED"
|
||||
DOOR_NOT_FOUND = "type:noc@hamburg.ccc.de,2026:DOOR_NOT_FOUND"
|
||||
LOCK_NOT_FOUND = "type:noc@hamburg.ccc.de,2026:LOCK_NOT_FOUND"
|
||||
|
||||
|
||||
class HttpProblemDetail(BaseModel):
|
||||
|
|
@ -38,12 +38,12 @@ class HttpProblemDetail(BaseModel):
|
|||
)
|
||||
|
||||
@classmethod
|
||||
def new_door_not_found(cls, requested_door: str, request_uri: str | URL) -> Self:
|
||||
def new_lock_not_found(cls, requested_lock: str, request_uri: str | URL) -> Self:
|
||||
return cls(
|
||||
type=HttpProblemType.DOOR_NOT_FOUND,
|
||||
type=HttpProblemType.LOCK_NOT_FOUND,
|
||||
status=status.HTTP_404_NOT_FOUND,
|
||||
title="Door not found",
|
||||
detail=f"You tried to interact with door {requested_door!r} that is not known to dooris",
|
||||
title="Lock not found",
|
||||
detail=f"You tried to interact with lock {requested_lock!r} that is not known to dooris",
|
||||
instance=str(request_uri),
|
||||
)
|
||||
|
||||
|
|
@ -73,3 +73,7 @@ class Lock(BaseModel):
|
|||
name: str
|
||||
id: str
|
||||
status: LockStatus
|
||||
|
||||
|
||||
class LockOperation(BaseModel):
|
||||
desired_state: Literal["open", "closed"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue