# Generated from soulfire/user.proto. DO NOT EDIT.
# Generated by protoc-gen-connectrpc-py v0.13.0 with parameter "protobuf=google".
# ruff: noqa: PGH004
# ruff: noqa
# pyright: reportDeprecated=false
# ty: ignore[unused-ignore-comment]
# ty: ignore[deprecated, unused-ignore-comment]
# fmt: off
from __future__ import annotations
from typing import Protocol, TYPE_CHECKING
from connectrpc.client import ConnectClient, ConnectClientSync
from connectrpc.code import Code
from connectrpc.compat import google_protobuf_binary_codec, google_protobuf_codecs
from connectrpc.compression.gzip import GzipCompression
from connectrpc.errors import ConnectError
from connectrpc.method import IdempotencyLevel, MethodInfo, StreamType
from connectrpc.protocol import ProtocolType
from connectrpc.server import ConnectASGIApplication, ConnectWSGIApplication, DEFAULT_READ_MAX_BYTES, Endpoint, EndpointSync
from pyqwest import Client, SyncClient
from .user_pb2 import DeleteUserPluginPermissionGrantRequest, DeleteUserPluginPermissionGrantResponse, GenerateUserAPITokenRequest, GenerateUserAPITokenResponse, InvalidateSessionsRequest, InvalidateSessionsResponse, ListUserPluginPermissionGrantsRequest, ListUserPluginPermissionGrantsResponse, SetUserPluginPermissionGrantRequest, UpdateUserRequest, UpdateUserResponse, UserCreateRequest, UserCreateResponse, UserDeleteRequest, UserDeleteResponse, UserInfoRequest, UserInfoResponse, UserListRequest, UserListResponse, UserPluginPermissionGrant
if TYPE_CHECKING:
from collections.abc import AsyncGenerator, Iterable, Mapping
from connectrpc.codec import Codec
from connectrpc.compression import Compression
from connectrpc.interceptor import Interceptor, InterceptorSync
from connectrpc.request import Headers, RequestContext
_DEFAULT_CODECS = google_protobuf_codecs()
_PROTO_BINARY_CODEC = google_protobuf_binary_codec()
_GZIP_COMPRESSION = GzipCompression()
[docs]
class UserService(Protocol):
"""
UserService provides user management functionality for the SoulFire system.
All methods require authentication via JWT token in the request metadata.
Most methods require specific global permissions (CREATE_USER, READ_USER, UPDATE_USER,
DELETE_USER, INVALIDATE_SESSIONS, or GENERATE_API_TOKEN).
Admin users automatically have all permissions.
Note: The root user (ID: 00000000-0000-0000-0000-000000000000) cannot be modified or deleted.
Note: Users cannot modify their own account through this service (use self-service endpoints instead).
"""
[docs]
async def create_user(self, request: UserCreateRequest, ctx: RequestContext[UserCreateRequest, UserCreateResponse], /) -> UserCreateResponse:
"""
Creates a new user account in the system.
Requires the CREATE_USER global permission.
Returns the UUID of the newly created user.
Error cases:
- INTERNAL: If username or email already exists, or validation fails
- PERMISSION_DENIED: If caller lacks CREATE_USER permission
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
async def delete_user(self, request: UserDeleteRequest, ctx: RequestContext[UserDeleteRequest, UserDeleteResponse], /) -> UserDeleteResponse:
"""
Deletes an existing user from the system.
Requires the DELETE_USER global permission.
Cascades to delete all owned instances and audit logs.
Also disconnects the user from any active log subscriptions.
Error cases:
- INTERNAL: If user not found, or attempting to delete self/root user
- PERMISSION_DENIED: If caller lacks DELETE_USER permission
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
async def list_users(self, request: UserListRequest, ctx: RequestContext[UserListRequest, UserListResponse], /) -> UserListResponse:
"""
Lists all users in the system.
Requires the READ_USER global permission.
Returns complete information for all users including timestamps.
Error cases:
- INTERNAL: If database query fails
- PERMISSION_DENIED: If caller lacks READ_USER permission
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
async def get_user_info(self, request: UserInfoRequest, ctx: RequestContext[UserInfoRequest, UserInfoResponse], /) -> UserInfoResponse:
"""
Retrieves detailed information about a specific user.
Requires the READ_USER global permission.
Error cases:
- INTERNAL: If user not found
- PERMISSION_DENIED: If caller lacks READ_USER permission
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
async def invalidate_sessions(self, request: InvalidateSessionsRequest, ctx: RequestContext[InvalidateSessionsRequest, InvalidateSessionsResponse], /) -> InvalidateSessionsResponse:
"""
Invalidates all active sessions for a user by updating their min_issued_at timestamp.
Requires the INVALIDATE_SESSIONS global permission.
After this call, all previously issued JWT tokens for the user become invalid,
effectively logging them out of all devices.
Error cases:
- INTERNAL: If user not found, or attempting to invalidate self/root user sessions
- PERMISSION_DENIED: If caller lacks INVALIDATE_SESSIONS permission
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
async def update_user(self, request: UpdateUserRequest, ctx: RequestContext[UpdateUserRequest, UpdateUserResponse], /) -> UpdateUserResponse:
"""
Updates an existing user's profile information.
Requires the UPDATE_USER global permission.
All profile fields (username, email, role) are updated to the provided values.
Error cases:
- INTERNAL: If user not found, attempting to update self/root user, or validation fails
- PERMISSION_DENIED: If caller lacks UPDATE_USER permission
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
async def generate_user_api_token(self, request: GenerateUserAPITokenRequest, ctx: RequestContext[GenerateUserAPITokenRequest, GenerateUserAPITokenResponse], /) -> GenerateUserAPITokenResponse:
"""
Generates a new API token (JWT) for a specific user.
Requires the GENERATE_API_TOKEN global permission.
The generated token has the "api" audience and does not expire.
The token can be invalidated by calling InvalidateSessions for the user.
Error cases:
- INTERNAL: If user not found, or attempting to generate token for self/root user
- PERMISSION_DENIED: If caller lacks GENERATE_API_TOKEN permission
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
async def list_user_plugin_permission_grants(self, request: ListUserPluginPermissionGrantsRequest, ctx: RequestContext[ListUserPluginPermissionGrantsRequest, ListUserPluginPermissionGrantsResponse], /) -> ListUserPluginPermissionGrantsResponse:
"""
Lists explicit dynamic plugin permission overrides for one user,
including inactive grants retained for plugins that are not installed.
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
async def set_user_plugin_permission_grant(self, request: SetUserPluginPermissionGrantRequest, ctx: RequestContext[SetUserPluginPermissionGrantRequest, UserPluginPermissionGrant], /) -> UserPluginPermissionGrant:
"""
Creates or replaces one explicit plugin permission override.
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
async def delete_user_plugin_permission_grant(self, request: DeleteUserPluginPermissionGrantRequest, ctx: RequestContext[DeleteUserPluginPermissionGrantRequest, DeleteUserPluginPermissionGrantResponse], /) -> DeleteUserPluginPermissionGrantResponse:
"""
Removes one explicit override so the plugin permission's default grant
policy applies again.
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
class UserServiceASGIApplication(ConnectASGIApplication[UserService]):
def __init__(
self,
service: UserService | AsyncGenerator[UserService],
*,
interceptors: Iterable[Interceptor] = (),
read_max_bytes: int | None = DEFAULT_READ_MAX_BYTES,
compressions: Iterable[Compression] | None = None,
codecs: Iterable[Codec] | None = _DEFAULT_CODECS,
) -> None:
super().__init__(
service=service,
endpoints=lambda svc: {
"/soulfire.v1.UserService/CreateUser": Endpoint.unary(
method=MethodInfo(
name="CreateUser",
service_name="soulfire.v1.UserService",
input=UserCreateRequest,
output=UserCreateResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
function=svc.create_user,
),
"/soulfire.v1.UserService/DeleteUser": Endpoint.unary(
method=MethodInfo(
name="DeleteUser",
service_name="soulfire.v1.UserService",
input=UserDeleteRequest,
output=UserDeleteResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
function=svc.delete_user,
),
"/soulfire.v1.UserService/ListUsers": Endpoint.unary(
method=MethodInfo(
name="ListUsers",
service_name="soulfire.v1.UserService",
input=UserListRequest,
output=UserListResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
function=svc.list_users,
),
"/soulfire.v1.UserService/GetUserInfo": Endpoint.unary(
method=MethodInfo(
name="GetUserInfo",
service_name="soulfire.v1.UserService",
input=UserInfoRequest,
output=UserInfoResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
function=svc.get_user_info,
),
"/soulfire.v1.UserService/InvalidateSessions": Endpoint.unary(
method=MethodInfo(
name="InvalidateSessions",
service_name="soulfire.v1.UserService",
input=InvalidateSessionsRequest,
output=InvalidateSessionsResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
function=svc.invalidate_sessions,
),
"/soulfire.v1.UserService/UpdateUser": Endpoint.unary(
method=MethodInfo(
name="UpdateUser",
service_name="soulfire.v1.UserService",
input=UpdateUserRequest,
output=UpdateUserResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
function=svc.update_user,
),
"/soulfire.v1.UserService/GenerateUserAPIToken": Endpoint.unary(
method=MethodInfo(
name="GenerateUserAPIToken",
service_name="soulfire.v1.UserService",
input=GenerateUserAPITokenRequest,
output=GenerateUserAPITokenResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
function=svc.generate_user_api_token,
),
"/soulfire.v1.UserService/ListUserPluginPermissionGrants": Endpoint.unary(
method=MethodInfo(
name="ListUserPluginPermissionGrants",
service_name="soulfire.v1.UserService",
input=ListUserPluginPermissionGrantsRequest,
output=ListUserPluginPermissionGrantsResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
function=svc.list_user_plugin_permission_grants,
),
"/soulfire.v1.UserService/SetUserPluginPermissionGrant": Endpoint.unary(
method=MethodInfo(
name="SetUserPluginPermissionGrant",
service_name="soulfire.v1.UserService",
input=SetUserPluginPermissionGrantRequest,
output=UserPluginPermissionGrant,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
function=svc.set_user_plugin_permission_grant,
),
"/soulfire.v1.UserService/DeleteUserPluginPermissionGrant": Endpoint.unary(
method=MethodInfo(
name="DeleteUserPluginPermissionGrant",
service_name="soulfire.v1.UserService",
input=DeleteUserPluginPermissionGrantRequest,
output=DeleteUserPluginPermissionGrantResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
function=svc.delete_user_plugin_permission_grant,
),
},
interceptors=interceptors,
read_max_bytes=read_max_bytes,
compressions=compressions,
codecs=codecs,
)
@property
def path(self) -> str:
"""Returns the URL path to mount the application to when serving multiple applications."""
return "/soulfire.v1.UserService"
[docs]
class UserServiceClient(ConnectClient):
"""
UserService provides user management functionality for the SoulFire system.
All methods require authentication via JWT token in the request metadata.
Most methods require specific global permissions (CREATE_USER, READ_USER, UPDATE_USER,
DELETE_USER, INVALIDATE_SESSIONS, or GENERATE_API_TOKEN).
Admin users automatically have all permissions.
Note: The root user (ID: 00000000-0000-0000-0000-000000000000) cannot be modified or deleted.
Note: Users cannot modify their own account through this service (use self-service endpoints instead).
"""
def __init__(
self,
address: str,
*,
codec: Codec | None = _PROTO_BINARY_CODEC,
protocol: ProtocolType = ProtocolType.CONNECT,
accept_compression: Iterable[Compression] | None = None,
send_compression: Compression | None = _GZIP_COMPRESSION,
timeout_ms: int | None = None,
read_max_bytes: int | None = None,
interceptors: Iterable[Interceptor] = (),
http_client: Client | None = None,
) -> None:
super().__init__(
address=address,
codec=codec,
protocol=protocol,
accept_compression=accept_compression,
send_compression=send_compression,
timeout_ms=timeout_ms,
read_max_bytes=read_max_bytes,
interceptors=interceptors,
http_client=http_client,
)
[docs]
async def create_user(
self,
request: UserCreateRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> UserCreateResponse:
"""
Creates a new user account in the system.
Requires the CREATE_USER global permission.
Returns the UUID of the newly created user.
Error cases:
- INTERNAL: If username or email already exists, or validation fails
- PERMISSION_DENIED: If caller lacks CREATE_USER permission
"""
return await self.execute_unary(
request=request,
method=MethodInfo(
name="CreateUser",
service_name="soulfire.v1.UserService",
input=UserCreateRequest,
output=UserCreateResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
async def delete_user(
self,
request: UserDeleteRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> UserDeleteResponse:
"""
Deletes an existing user from the system.
Requires the DELETE_USER global permission.
Cascades to delete all owned instances and audit logs.
Also disconnects the user from any active log subscriptions.
Error cases:
- INTERNAL: If user not found, or attempting to delete self/root user
- PERMISSION_DENIED: If caller lacks DELETE_USER permission
"""
return await self.execute_unary(
request=request,
method=MethodInfo(
name="DeleteUser",
service_name="soulfire.v1.UserService",
input=UserDeleteRequest,
output=UserDeleteResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
async def list_users(
self,
request: UserListRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> UserListResponse:
"""
Lists all users in the system.
Requires the READ_USER global permission.
Returns complete information for all users including timestamps.
Error cases:
- INTERNAL: If database query fails
- PERMISSION_DENIED: If caller lacks READ_USER permission
"""
return await self.execute_unary(
request=request,
method=MethodInfo(
name="ListUsers",
service_name="soulfire.v1.UserService",
input=UserListRequest,
output=UserListResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
async def get_user_info(
self,
request: UserInfoRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> UserInfoResponse:
"""
Retrieves detailed information about a specific user.
Requires the READ_USER global permission.
Error cases:
- INTERNAL: If user not found
- PERMISSION_DENIED: If caller lacks READ_USER permission
"""
return await self.execute_unary(
request=request,
method=MethodInfo(
name="GetUserInfo",
service_name="soulfire.v1.UserService",
input=UserInfoRequest,
output=UserInfoResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
async def invalidate_sessions(
self,
request: InvalidateSessionsRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> InvalidateSessionsResponse:
"""
Invalidates all active sessions for a user by updating their min_issued_at timestamp.
Requires the INVALIDATE_SESSIONS global permission.
After this call, all previously issued JWT tokens for the user become invalid,
effectively logging them out of all devices.
Error cases:
- INTERNAL: If user not found, or attempting to invalidate self/root user sessions
- PERMISSION_DENIED: If caller lacks INVALIDATE_SESSIONS permission
"""
return await self.execute_unary(
request=request,
method=MethodInfo(
name="InvalidateSessions",
service_name="soulfire.v1.UserService",
input=InvalidateSessionsRequest,
output=InvalidateSessionsResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
async def update_user(
self,
request: UpdateUserRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> UpdateUserResponse:
"""
Updates an existing user's profile information.
Requires the UPDATE_USER global permission.
All profile fields (username, email, role) are updated to the provided values.
Error cases:
- INTERNAL: If user not found, attempting to update self/root user, or validation fails
- PERMISSION_DENIED: If caller lacks UPDATE_USER permission
"""
return await self.execute_unary(
request=request,
method=MethodInfo(
name="UpdateUser",
service_name="soulfire.v1.UserService",
input=UpdateUserRequest,
output=UpdateUserResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
async def generate_user_api_token(
self,
request: GenerateUserAPITokenRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> GenerateUserAPITokenResponse:
"""
Generates a new API token (JWT) for a specific user.
Requires the GENERATE_API_TOKEN global permission.
The generated token has the "api" audience and does not expire.
The token can be invalidated by calling InvalidateSessions for the user.
Error cases:
- INTERNAL: If user not found, or attempting to generate token for self/root user
- PERMISSION_DENIED: If caller lacks GENERATE_API_TOKEN permission
"""
return await self.execute_unary(
request=request,
method=MethodInfo(
name="GenerateUserAPIToken",
service_name="soulfire.v1.UserService",
input=GenerateUserAPITokenRequest,
output=GenerateUserAPITokenResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
async def list_user_plugin_permission_grants(
self,
request: ListUserPluginPermissionGrantsRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> ListUserPluginPermissionGrantsResponse:
"""
Lists explicit dynamic plugin permission overrides for one user,
including inactive grants retained for plugins that are not installed.
"""
return await self.execute_unary(
request=request,
method=MethodInfo(
name="ListUserPluginPermissionGrants",
service_name="soulfire.v1.UserService",
input=ListUserPluginPermissionGrantsRequest,
output=ListUserPluginPermissionGrantsResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
async def set_user_plugin_permission_grant(
self,
request: SetUserPluginPermissionGrantRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> UserPluginPermissionGrant:
"""
Creates or replaces one explicit plugin permission override.
"""
return await self.execute_unary(
request=request,
method=MethodInfo(
name="SetUserPluginPermissionGrant",
service_name="soulfire.v1.UserService",
input=SetUserPluginPermissionGrantRequest,
output=UserPluginPermissionGrant,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
async def delete_user_plugin_permission_grant(
self,
request: DeleteUserPluginPermissionGrantRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> DeleteUserPluginPermissionGrantResponse:
"""
Removes one explicit override so the plugin permission's default grant
policy applies again.
"""
return await self.execute_unary(
request=request,
method=MethodInfo(
name="DeleteUserPluginPermissionGrant",
service_name="soulfire.v1.UserService",
input=DeleteUserPluginPermissionGrantRequest,
output=DeleteUserPluginPermissionGrantResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
class UserServiceSync(Protocol):
"""
UserService provides user management functionality for the SoulFire system.
All methods require authentication via JWT token in the request metadata.
Most methods require specific global permissions (CREATE_USER, READ_USER, UPDATE_USER,
DELETE_USER, INVALIDATE_SESSIONS, or GENERATE_API_TOKEN).
Admin users automatically have all permissions.
Note: The root user (ID: 00000000-0000-0000-0000-000000000000) cannot be modified or deleted.
Note: Users cannot modify their own account through this service (use self-service endpoints instead).
"""
[docs]
def create_user(self, request: UserCreateRequest, ctx: RequestContext[UserCreateRequest, UserCreateResponse], /) -> UserCreateResponse:
"""
Creates a new user account in the system.
Requires the CREATE_USER global permission.
Returns the UUID of the newly created user.
Error cases:
- INTERNAL: If username or email already exists, or validation fails
- PERMISSION_DENIED: If caller lacks CREATE_USER permission
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
def delete_user(self, request: UserDeleteRequest, ctx: RequestContext[UserDeleteRequest, UserDeleteResponse], /) -> UserDeleteResponse:
"""
Deletes an existing user from the system.
Requires the DELETE_USER global permission.
Cascades to delete all owned instances and audit logs.
Also disconnects the user from any active log subscriptions.
Error cases:
- INTERNAL: If user not found, or attempting to delete self/root user
- PERMISSION_DENIED: If caller lacks DELETE_USER permission
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
def list_users(self, request: UserListRequest, ctx: RequestContext[UserListRequest, UserListResponse], /) -> UserListResponse:
"""
Lists all users in the system.
Requires the READ_USER global permission.
Returns complete information for all users including timestamps.
Error cases:
- INTERNAL: If database query fails
- PERMISSION_DENIED: If caller lacks READ_USER permission
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
def get_user_info(self, request: UserInfoRequest, ctx: RequestContext[UserInfoRequest, UserInfoResponse], /) -> UserInfoResponse:
"""
Retrieves detailed information about a specific user.
Requires the READ_USER global permission.
Error cases:
- INTERNAL: If user not found
- PERMISSION_DENIED: If caller lacks READ_USER permission
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
def invalidate_sessions(self, request: InvalidateSessionsRequest, ctx: RequestContext[InvalidateSessionsRequest, InvalidateSessionsResponse], /) -> InvalidateSessionsResponse:
"""
Invalidates all active sessions for a user by updating their min_issued_at timestamp.
Requires the INVALIDATE_SESSIONS global permission.
After this call, all previously issued JWT tokens for the user become invalid,
effectively logging them out of all devices.
Error cases:
- INTERNAL: If user not found, or attempting to invalidate self/root user sessions
- PERMISSION_DENIED: If caller lacks INVALIDATE_SESSIONS permission
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
def update_user(self, request: UpdateUserRequest, ctx: RequestContext[UpdateUserRequest, UpdateUserResponse], /) -> UpdateUserResponse:
"""
Updates an existing user's profile information.
Requires the UPDATE_USER global permission.
All profile fields (username, email, role) are updated to the provided values.
Error cases:
- INTERNAL: If user not found, attempting to update self/root user, or validation fails
- PERMISSION_DENIED: If caller lacks UPDATE_USER permission
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
def generate_user_api_token(self, request: GenerateUserAPITokenRequest, ctx: RequestContext[GenerateUserAPITokenRequest, GenerateUserAPITokenResponse], /) -> GenerateUserAPITokenResponse:
"""
Generates a new API token (JWT) for a specific user.
Requires the GENERATE_API_TOKEN global permission.
The generated token has the "api" audience and does not expire.
The token can be invalidated by calling InvalidateSessions for the user.
Error cases:
- INTERNAL: If user not found, or attempting to generate token for self/root user
- PERMISSION_DENIED: If caller lacks GENERATE_API_TOKEN permission
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
def list_user_plugin_permission_grants(self, request: ListUserPluginPermissionGrantsRequest, ctx: RequestContext[ListUserPluginPermissionGrantsRequest, ListUserPluginPermissionGrantsResponse], /) -> ListUserPluginPermissionGrantsResponse:
"""
Lists explicit dynamic plugin permission overrides for one user,
including inactive grants retained for plugins that are not installed.
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
def set_user_plugin_permission_grant(self, request: SetUserPluginPermissionGrantRequest, ctx: RequestContext[SetUserPluginPermissionGrantRequest, UserPluginPermissionGrant], /) -> UserPluginPermissionGrant:
"""
Creates or replaces one explicit plugin permission override.
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
def delete_user_plugin_permission_grant(self, request: DeleteUserPluginPermissionGrantRequest, ctx: RequestContext[DeleteUserPluginPermissionGrantRequest, DeleteUserPluginPermissionGrantResponse], /) -> DeleteUserPluginPermissionGrantResponse:
"""
Removes one explicit override so the plugin permission's default grant
policy applies again.
"""
raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs]
class UserServiceWSGIApplication(ConnectWSGIApplication):
def __init__(
self,
service: UserServiceSync,
interceptors: Iterable[InterceptorSync] = (),
read_max_bytes: int | None = DEFAULT_READ_MAX_BYTES,
compressions: Iterable[Compression] | None = None,
codecs: Iterable[Codec] | None = _DEFAULT_CODECS,
) -> None:
super().__init__(
endpoints={
"/soulfire.v1.UserService/CreateUser": EndpointSync.unary(
method=MethodInfo(
name="CreateUser",
service_name="soulfire.v1.UserService",
input=UserCreateRequest,
output=UserCreateResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
function=service.create_user,
),
"/soulfire.v1.UserService/DeleteUser": EndpointSync.unary(
method=MethodInfo(
name="DeleteUser",
service_name="soulfire.v1.UserService",
input=UserDeleteRequest,
output=UserDeleteResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
function=service.delete_user,
),
"/soulfire.v1.UserService/ListUsers": EndpointSync.unary(
method=MethodInfo(
name="ListUsers",
service_name="soulfire.v1.UserService",
input=UserListRequest,
output=UserListResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
function=service.list_users,
),
"/soulfire.v1.UserService/GetUserInfo": EndpointSync.unary(
method=MethodInfo(
name="GetUserInfo",
service_name="soulfire.v1.UserService",
input=UserInfoRequest,
output=UserInfoResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
function=service.get_user_info,
),
"/soulfire.v1.UserService/InvalidateSessions": EndpointSync.unary(
method=MethodInfo(
name="InvalidateSessions",
service_name="soulfire.v1.UserService",
input=InvalidateSessionsRequest,
output=InvalidateSessionsResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
function=service.invalidate_sessions,
),
"/soulfire.v1.UserService/UpdateUser": EndpointSync.unary(
method=MethodInfo(
name="UpdateUser",
service_name="soulfire.v1.UserService",
input=UpdateUserRequest,
output=UpdateUserResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
function=service.update_user,
),
"/soulfire.v1.UserService/GenerateUserAPIToken": EndpointSync.unary(
method=MethodInfo(
name="GenerateUserAPIToken",
service_name="soulfire.v1.UserService",
input=GenerateUserAPITokenRequest,
output=GenerateUserAPITokenResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
function=service.generate_user_api_token,
),
"/soulfire.v1.UserService/ListUserPluginPermissionGrants": EndpointSync.unary(
method=MethodInfo(
name="ListUserPluginPermissionGrants",
service_name="soulfire.v1.UserService",
input=ListUserPluginPermissionGrantsRequest,
output=ListUserPluginPermissionGrantsResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
function=service.list_user_plugin_permission_grants,
),
"/soulfire.v1.UserService/SetUserPluginPermissionGrant": EndpointSync.unary(
method=MethodInfo(
name="SetUserPluginPermissionGrant",
service_name="soulfire.v1.UserService",
input=SetUserPluginPermissionGrantRequest,
output=UserPluginPermissionGrant,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
function=service.set_user_plugin_permission_grant,
),
"/soulfire.v1.UserService/DeleteUserPluginPermissionGrant": EndpointSync.unary(
method=MethodInfo(
name="DeleteUserPluginPermissionGrant",
service_name="soulfire.v1.UserService",
input=DeleteUserPluginPermissionGrantRequest,
output=DeleteUserPluginPermissionGrantResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
function=service.delete_user_plugin_permission_grant,
),
},
interceptors=interceptors,
read_max_bytes=read_max_bytes,
compressions=compressions,
codecs=codecs,
)
@property
def path(self) -> str:
"""Returns the URL path to mount the application to when serving multiple applications."""
return "/soulfire.v1.UserService"
[docs]
class UserServiceClientSync(ConnectClientSync):
"""
UserService provides user management functionality for the SoulFire system.
All methods require authentication via JWT token in the request metadata.
Most methods require specific global permissions (CREATE_USER, READ_USER, UPDATE_USER,
DELETE_USER, INVALIDATE_SESSIONS, or GENERATE_API_TOKEN).
Admin users automatically have all permissions.
Note: The root user (ID: 00000000-0000-0000-0000-000000000000) cannot be modified or deleted.
Note: Users cannot modify their own account through this service (use self-service endpoints instead).
"""
def __init__(
self,
address: str,
*,
codec: Codec | None = _PROTO_BINARY_CODEC,
protocol: ProtocolType = ProtocolType.CONNECT,
accept_compression: Iterable[Compression] | None = None,
send_compression: Compression | None = _GZIP_COMPRESSION,
timeout_ms: int | None = None,
read_max_bytes: int | None = None,
interceptors: Iterable[InterceptorSync] = (),
http_client: SyncClient | None = None,
) -> None:
super().__init__(
address=address,
codec=codec,
protocol=protocol,
accept_compression=accept_compression,
send_compression=send_compression,
timeout_ms=timeout_ms,
read_max_bytes=read_max_bytes,
interceptors=interceptors,
http_client=http_client,
)
[docs]
def create_user(
self,
request: UserCreateRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> UserCreateResponse:
"""
Creates a new user account in the system.
Requires the CREATE_USER global permission.
Returns the UUID of the newly created user.
Error cases:
- INTERNAL: If username or email already exists, or validation fails
- PERMISSION_DENIED: If caller lacks CREATE_USER permission
"""
return self.execute_unary(
request=request,
method=MethodInfo(
name="CreateUser",
service_name="soulfire.v1.UserService",
input=UserCreateRequest,
output=UserCreateResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
def delete_user(
self,
request: UserDeleteRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> UserDeleteResponse:
"""
Deletes an existing user from the system.
Requires the DELETE_USER global permission.
Cascades to delete all owned instances and audit logs.
Also disconnects the user from any active log subscriptions.
Error cases:
- INTERNAL: If user not found, or attempting to delete self/root user
- PERMISSION_DENIED: If caller lacks DELETE_USER permission
"""
return self.execute_unary(
request=request,
method=MethodInfo(
name="DeleteUser",
service_name="soulfire.v1.UserService",
input=UserDeleteRequest,
output=UserDeleteResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
def list_users(
self,
request: UserListRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> UserListResponse:
"""
Lists all users in the system.
Requires the READ_USER global permission.
Returns complete information for all users including timestamps.
Error cases:
- INTERNAL: If database query fails
- PERMISSION_DENIED: If caller lacks READ_USER permission
"""
return self.execute_unary(
request=request,
method=MethodInfo(
name="ListUsers",
service_name="soulfire.v1.UserService",
input=UserListRequest,
output=UserListResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
def get_user_info(
self,
request: UserInfoRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> UserInfoResponse:
"""
Retrieves detailed information about a specific user.
Requires the READ_USER global permission.
Error cases:
- INTERNAL: If user not found
- PERMISSION_DENIED: If caller lacks READ_USER permission
"""
return self.execute_unary(
request=request,
method=MethodInfo(
name="GetUserInfo",
service_name="soulfire.v1.UserService",
input=UserInfoRequest,
output=UserInfoResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
def invalidate_sessions(
self,
request: InvalidateSessionsRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> InvalidateSessionsResponse:
"""
Invalidates all active sessions for a user by updating their min_issued_at timestamp.
Requires the INVALIDATE_SESSIONS global permission.
After this call, all previously issued JWT tokens for the user become invalid,
effectively logging them out of all devices.
Error cases:
- INTERNAL: If user not found, or attempting to invalidate self/root user sessions
- PERMISSION_DENIED: If caller lacks INVALIDATE_SESSIONS permission
"""
return self.execute_unary(
request=request,
method=MethodInfo(
name="InvalidateSessions",
service_name="soulfire.v1.UserService",
input=InvalidateSessionsRequest,
output=InvalidateSessionsResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
def update_user(
self,
request: UpdateUserRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> UpdateUserResponse:
"""
Updates an existing user's profile information.
Requires the UPDATE_USER global permission.
All profile fields (username, email, role) are updated to the provided values.
Error cases:
- INTERNAL: If user not found, attempting to update self/root user, or validation fails
- PERMISSION_DENIED: If caller lacks UPDATE_USER permission
"""
return self.execute_unary(
request=request,
method=MethodInfo(
name="UpdateUser",
service_name="soulfire.v1.UserService",
input=UpdateUserRequest,
output=UpdateUserResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
def generate_user_api_token(
self,
request: GenerateUserAPITokenRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> GenerateUserAPITokenResponse:
"""
Generates a new API token (JWT) for a specific user.
Requires the GENERATE_API_TOKEN global permission.
The generated token has the "api" audience and does not expire.
The token can be invalidated by calling InvalidateSessions for the user.
Error cases:
- INTERNAL: If user not found, or attempting to generate token for self/root user
- PERMISSION_DENIED: If caller lacks GENERATE_API_TOKEN permission
"""
return self.execute_unary(
request=request,
method=MethodInfo(
name="GenerateUserAPIToken",
service_name="soulfire.v1.UserService",
input=GenerateUserAPITokenRequest,
output=GenerateUserAPITokenResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
def list_user_plugin_permission_grants(
self,
request: ListUserPluginPermissionGrantsRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> ListUserPluginPermissionGrantsResponse:
"""
Lists explicit dynamic plugin permission overrides for one user,
including inactive grants retained for plugins that are not installed.
"""
return self.execute_unary(
request=request,
method=MethodInfo(
name="ListUserPluginPermissionGrants",
service_name="soulfire.v1.UserService",
input=ListUserPluginPermissionGrantsRequest,
output=ListUserPluginPermissionGrantsResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
def set_user_plugin_permission_grant(
self,
request: SetUserPluginPermissionGrantRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> UserPluginPermissionGrant:
"""
Creates or replaces one explicit plugin permission override.
"""
return self.execute_unary(
request=request,
method=MethodInfo(
name="SetUserPluginPermissionGrant",
service_name="soulfire.v1.UserService",
input=SetUserPluginPermissionGrantRequest,
output=UserPluginPermissionGrant,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
headers=headers,
timeout_ms=timeout_ms,
)
[docs]
def delete_user_plugin_permission_grant(
self,
request: DeleteUserPluginPermissionGrantRequest,
*,
headers: Headers | Mapping[str, str] | None = None,
timeout_ms: int | None = None,
) -> DeleteUserPluginPermissionGrantResponse:
"""
Removes one explicit override so the plugin permission's default grant
policy applies again.
"""
return self.execute_unary(
request=request,
method=MethodInfo(
name="DeleteUserPluginPermissionGrant",
service_name="soulfire.v1.UserService",
input=DeleteUserPluginPermissionGrantRequest,
output=DeleteUserPluginPermissionGrantResponse,
idempotency_level=IdempotencyLevel.UNKNOWN,
stream_type=StreamType.UNARY,
),
headers=headers,
timeout_ms=timeout_ms,
)