feat: add disable_device_pairing option to gateway configuration
This commit is contained in:
@@ -37,11 +37,13 @@ def _query_to_resolve_input(
|
||||
board_id: str | None = Query(default=None),
|
||||
gateway_url: str | None = Query(default=None),
|
||||
gateway_token: str | None = Query(default=None),
|
||||
gateway_disable_device_pairing: bool = Query(default=False),
|
||||
) -> GatewayResolveQuery:
|
||||
return GatewaySessionService.to_resolve_query(
|
||||
board_id=board_id,
|
||||
gateway_url=gateway_url,
|
||||
gateway_token=gateway_token,
|
||||
gateway_disable_device_pairing=gateway_disable_device_pairing,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -94,7 +94,11 @@ async def create_gateway(
|
||||
) -> Gateway:
|
||||
"""Create a gateway and provision or refresh its main agent."""
|
||||
service = GatewayAdminLifecycleService(session)
|
||||
await service.assert_gateway_runtime_compatible(url=payload.url, token=payload.token)
|
||||
await service.assert_gateway_runtime_compatible(
|
||||
url=payload.url,
|
||||
token=payload.token,
|
||||
disable_device_pairing=payload.disable_device_pairing,
|
||||
)
|
||||
data = payload.model_dump()
|
||||
gateway_id = uuid4()
|
||||
data["id"] = gateway_id
|
||||
@@ -134,12 +138,23 @@ async def update_gateway(
|
||||
organization_id=ctx.organization.id,
|
||||
)
|
||||
updates = payload.model_dump(exclude_unset=True)
|
||||
if "url" in updates or "token" in updates:
|
||||
if (
|
||||
"url" in updates
|
||||
or "token" in updates
|
||||
or "disable_device_pairing" in updates
|
||||
):
|
||||
raw_next_url = updates.get("url", gateway.url)
|
||||
next_url = raw_next_url.strip() if isinstance(raw_next_url, str) else ""
|
||||
next_token = updates.get("token", gateway.token)
|
||||
next_disable_device_pairing = bool(
|
||||
updates.get("disable_device_pairing", gateway.disable_device_pairing),
|
||||
)
|
||||
if next_url:
|
||||
await service.assert_gateway_runtime_compatible(url=next_url, token=next_token)
|
||||
await service.assert_gateway_runtime_compatible(
|
||||
url=next_url,
|
||||
token=next_token,
|
||||
disable_device_pairing=next_disable_device_pairing,
|
||||
)
|
||||
await crud.patch(session, gateway, updates)
|
||||
await service.ensure_main_agent(gateway, auth, action="update")
|
||||
return gateway
|
||||
|
||||
Reference in New Issue
Block a user