diff --git a/turnstone/api/console_schemas.py b/turnstone/api/console_schemas.py index 85e0c5cb..28742970 100644 --- a/turnstone/api/console_schemas.py +++ b/turnstone/api/console_schemas.py @@ -347,4 +347,25 @@ class AuditEventInfo(BaseModel): class ListAuditEventsResponse(BaseModel): events: list[AuditEventInfo] + + +# --------------------------------------------------------------------------- +# Channels +# --------------------------------------------------------------------------- + + +class ChannelUserInfo(BaseModel): + channel_type: str + channel_user_id: str + user_id: str + created: str + + +class ListChannelUsersResponse(BaseModel): + channels: list[ChannelUserInfo] + + +class CreateChannelUserRequest(BaseModel): + channel_type: str = Field(..., description="Channel type (e.g. discord, slack)") + channel_user_id: str = Field(..., description="External channel user identifier") total: int diff --git a/turnstone/api/console_spec.py b/turnstone/api/console_spec.py index 797e0ecd..49eaec7a 100644 --- a/turnstone/api/console_spec.py +++ b/turnstone/api/console_spec.py @@ -10,6 +10,7 @@ if TYPE_CHECKING: from turnstone.api.console_schemas import ( AssignRoleRequest, AuditEventInfo, + ChannelUserInfo, ClusterNodesResponse, ClusterOverviewResponse, ClusterSnapshotResponse, @@ -17,10 +18,12 @@ from turnstone.api.console_schemas import ( ConsoleCreateWsRequest, ConsoleCreateWsResponse, ConsoleHealthResponse, + CreateChannelUserRequest, CreatePromptTemplateRequest, CreateRoleRequest, CreateToolPolicyRequest, ListAuditEventsResponse, + ListChannelUsersResponse, ListOrgsResponse, ListPromptTemplatesResponse, ListRolesResponse, @@ -219,6 +222,31 @@ CONSOLE_ENDPOINTS: list[EndpointSpec] = [ error_codes=[404], tags=["Admin"], ), + # --- Channels --- + EndpointSpec( + "/v1/api/admin/users/{user_id}/channels", + "GET", + "List channel links for a user", + response_model=ListChannelUsersResponse, + tags=["Admin"], + ), + EndpointSpec( + "/v1/api/admin/users/{user_id}/channels", + "POST", + "Link a channel account to a user", + request_model=CreateChannelUserRequest, + response_model=ChannelUserInfo, + error_codes=[400, 404, 409], + tags=["Admin"], + ), + EndpointSpec( + "/v1/api/admin/channels/{channel_type}/{channel_user_id}", + "DELETE", + "Unlink a channel account", + response_model=StatusResponse, + error_codes=[404], + tags=["Admin"], + ), # --- Schedules --- EndpointSpec( "/v1/api/admin/schedules", @@ -483,6 +511,9 @@ _ALL_MODELS: list[type[BaseModel]] = [ CreateTokenRequest, CreateTokenResponse, ListTokensResponse, + ChannelUserInfo, + CreateChannelUserRequest, + ListChannelUsersResponse, ClusterOverviewResponse, ClusterNodesResponse, ClusterWorkstreamsResponse,