Source code for soulfire.client_connect

# Generated from soulfire/client.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 .client_pb2 import ClientDataRequest, ClientDataResponse, GenerateAPITokenRequest, GenerateAPITokenResponse, GenerateWebDAVTokenRequest, GenerateWebDAVTokenResponse, InvalidateSelfSessionsRequest, InvalidateSelfSessionsResponse, UpdateSelfEmailRequest, UpdateSelfEmailResponse, UpdateSelfUsernameRequest, UpdateSelfUsernameResponse

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 ClientService(Protocol): """ Service for managing client/user-specific operations. All methods in this service operate on the currently authenticated user, identified via the JWT token in the Authorization header. Each method requires a specific GlobalPermission to be granted to the user. """
[docs] async def get_client_data(self, request: ClientDataRequest, ctx: RequestContext[ClientDataRequest, ClientDataResponse], /) -> ClientDataResponse: """ Retrieves comprehensive data about the authenticated client and the server. Returns user profile information, granted permissions, and server metadata. Required permission: READ_CLIENT_DATA Error cases: - PERMISSION_DENIED: User lacks READ_CLIENT_DATA permission - INTERNAL: Server error while fetching client data """ raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs] async def generate_web_dav_token(self, request: GenerateWebDAVTokenRequest, ctx: RequestContext[GenerateWebDAVTokenRequest, GenerateWebDAVTokenResponse], /) -> GenerateWebDAVTokenResponse: """ Generates a new JWT token specifically for WebDAV authentication. The generated token has the "webdav" audience and can only be used for WebDAV access. Required permission: GENERATE_SELF_WEBDAV_TOKEN Error cases: - PERMISSION_DENIED: User lacks GENERATE_SELF_WEBDAV_TOKEN permission - INTERNAL: Server error while generating token (e.g., user not found) """ raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs] async def generate_api_token(self, request: GenerateAPITokenRequest, ctx: RequestContext[GenerateAPITokenRequest, GenerateAPITokenResponse], /) -> GenerateAPITokenResponse: """ Generates a new JWT token for API authentication. The generated token has the "api" audience and can be used for gRPC/HTTP API calls. Required permission: GENERATE_SELF_API_TOKEN Error cases: - PERMISSION_DENIED: User lacks GENERATE_SELF_API_TOKEN permission - INTERNAL: Server error while generating token (e.g., user not found) """ raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs] async def update_self_username(self, request: UpdateSelfUsernameRequest, ctx: RequestContext[UpdateSelfUsernameRequest, UpdateSelfUsernameResponse], /) -> UpdateSelfUsernameResponse: """ Updates the username of the currently authenticated user. The change is persisted to the database immediately. Required permission: UPDATE_SELF_USERNAME Error cases: - PERMISSION_DENIED: User lacks UPDATE_SELF_USERNAME permission - INTERNAL: Server error while updating (e.g., user not found in database) """ raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs] async def update_self_email(self, request: UpdateSelfEmailRequest, ctx: RequestContext[UpdateSelfEmailRequest, UpdateSelfEmailResponse], /) -> UpdateSelfEmailResponse: """ Updates the email address of the currently authenticated user. The change is persisted to the database immediately. Required permission: UPDATE_SELF_EMAIL Error cases: - PERMISSION_DENIED: User lacks UPDATE_SELF_EMAIL permission - INTERNAL: Server error while updating (e.g., user not found in database) """ raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs] async def invalidate_self_sessions(self, request: InvalidateSelfSessionsRequest, ctx: RequestContext[InvalidateSelfSessionsRequest, InvalidateSelfSessionsResponse], /) -> InvalidateSelfSessionsResponse: """ Invalidates all existing sessions for the currently authenticated user. This is done by setting the user's minIssuedAt timestamp to the current time, which causes all previously issued JWT tokens to become invalid. After calling this method, the user will need to re-authenticate on all devices. Required permission: INVALIDATE_SELF_SESSIONS Error cases: - PERMISSION_DENIED: User lacks INVALIDATE_SELF_SESSIONS permission - INTERNAL: Server error while invalidating sessions (e.g., user not found) """ raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs] class ClientServiceASGIApplication(ConnectASGIApplication[ClientService]): def __init__( self, service: ClientService | AsyncGenerator[ClientService], *, 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.ClientService/GetClientData": Endpoint.unary( method=MethodInfo( name="GetClientData", service_name="soulfire.v1.ClientService", input=ClientDataRequest, output=ClientDataResponse, idempotency_level=IdempotencyLevel.UNKNOWN, stream_type=StreamType.UNARY, ), function=svc.get_client_data, ), "/soulfire.v1.ClientService/GenerateWebDAVToken": Endpoint.unary( method=MethodInfo( name="GenerateWebDAVToken", service_name="soulfire.v1.ClientService", input=GenerateWebDAVTokenRequest, output=GenerateWebDAVTokenResponse, idempotency_level=IdempotencyLevel.UNKNOWN, stream_type=StreamType.UNARY, ), function=svc.generate_web_dav_token, ), "/soulfire.v1.ClientService/GenerateAPIToken": Endpoint.unary( method=MethodInfo( name="GenerateAPIToken", service_name="soulfire.v1.ClientService", input=GenerateAPITokenRequest, output=GenerateAPITokenResponse, idempotency_level=IdempotencyLevel.UNKNOWN, stream_type=StreamType.UNARY, ), function=svc.generate_api_token, ), "/soulfire.v1.ClientService/UpdateSelfUsername": Endpoint.unary( method=MethodInfo( name="UpdateSelfUsername", service_name="soulfire.v1.ClientService", input=UpdateSelfUsernameRequest, output=UpdateSelfUsernameResponse, idempotency_level=IdempotencyLevel.UNKNOWN, stream_type=StreamType.UNARY, ), function=svc.update_self_username, ), "/soulfire.v1.ClientService/UpdateSelfEmail": Endpoint.unary( method=MethodInfo( name="UpdateSelfEmail", service_name="soulfire.v1.ClientService", input=UpdateSelfEmailRequest, output=UpdateSelfEmailResponse, idempotency_level=IdempotencyLevel.UNKNOWN, stream_type=StreamType.UNARY, ), function=svc.update_self_email, ), "/soulfire.v1.ClientService/InvalidateSelfSessions": Endpoint.unary( method=MethodInfo( name="InvalidateSelfSessions", service_name="soulfire.v1.ClientService", input=InvalidateSelfSessionsRequest, output=InvalidateSelfSessionsResponse, idempotency_level=IdempotencyLevel.UNKNOWN, stream_type=StreamType.UNARY, ), function=svc.invalidate_self_sessions, ), }, 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.ClientService"
[docs] class ClientServiceClient(ConnectClient): """ Service for managing client/user-specific operations. All methods in this service operate on the currently authenticated user, identified via the JWT token in the Authorization header. Each method requires a specific GlobalPermission to be granted to the user. """ 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 get_client_data( self, request: ClientDataRequest, *, headers: Headers | Mapping[str, str] | None = None, timeout_ms: int | None = None, ) -> ClientDataResponse: """ Retrieves comprehensive data about the authenticated client and the server. Returns user profile information, granted permissions, and server metadata. Required permission: READ_CLIENT_DATA Error cases: - PERMISSION_DENIED: User lacks READ_CLIENT_DATA permission - INTERNAL: Server error while fetching client data """ return await self.execute_unary( request=request, method=MethodInfo( name="GetClientData", service_name="soulfire.v1.ClientService", input=ClientDataRequest, output=ClientDataResponse, idempotency_level=IdempotencyLevel.UNKNOWN, stream_type=StreamType.UNARY, ), headers=headers, timeout_ms=timeout_ms, )
[docs] async def generate_web_dav_token( self, request: GenerateWebDAVTokenRequest, *, headers: Headers | Mapping[str, str] | None = None, timeout_ms: int | None = None, ) -> GenerateWebDAVTokenResponse: """ Generates a new JWT token specifically for WebDAV authentication. The generated token has the "webdav" audience and can only be used for WebDAV access. Required permission: GENERATE_SELF_WEBDAV_TOKEN Error cases: - PERMISSION_DENIED: User lacks GENERATE_SELF_WEBDAV_TOKEN permission - INTERNAL: Server error while generating token (e.g., user not found) """ return await self.execute_unary( request=request, method=MethodInfo( name="GenerateWebDAVToken", service_name="soulfire.v1.ClientService", input=GenerateWebDAVTokenRequest, output=GenerateWebDAVTokenResponse, idempotency_level=IdempotencyLevel.UNKNOWN, stream_type=StreamType.UNARY, ), headers=headers, timeout_ms=timeout_ms, )
[docs] async def generate_api_token( self, request: GenerateAPITokenRequest, *, headers: Headers | Mapping[str, str] | None = None, timeout_ms: int | None = None, ) -> GenerateAPITokenResponse: """ Generates a new JWT token for API authentication. The generated token has the "api" audience and can be used for gRPC/HTTP API calls. Required permission: GENERATE_SELF_API_TOKEN Error cases: - PERMISSION_DENIED: User lacks GENERATE_SELF_API_TOKEN permission - INTERNAL: Server error while generating token (e.g., user not found) """ return await self.execute_unary( request=request, method=MethodInfo( name="GenerateAPIToken", service_name="soulfire.v1.ClientService", input=GenerateAPITokenRequest, output=GenerateAPITokenResponse, idempotency_level=IdempotencyLevel.UNKNOWN, stream_type=StreamType.UNARY, ), headers=headers, timeout_ms=timeout_ms, )
[docs] async def update_self_username( self, request: UpdateSelfUsernameRequest, *, headers: Headers | Mapping[str, str] | None = None, timeout_ms: int | None = None, ) -> UpdateSelfUsernameResponse: """ Updates the username of the currently authenticated user. The change is persisted to the database immediately. Required permission: UPDATE_SELF_USERNAME Error cases: - PERMISSION_DENIED: User lacks UPDATE_SELF_USERNAME permission - INTERNAL: Server error while updating (e.g., user not found in database) """ return await self.execute_unary( request=request, method=MethodInfo( name="UpdateSelfUsername", service_name="soulfire.v1.ClientService", input=UpdateSelfUsernameRequest, output=UpdateSelfUsernameResponse, idempotency_level=IdempotencyLevel.UNKNOWN, stream_type=StreamType.UNARY, ), headers=headers, timeout_ms=timeout_ms, )
[docs] async def update_self_email( self, request: UpdateSelfEmailRequest, *, headers: Headers | Mapping[str, str] | None = None, timeout_ms: int | None = None, ) -> UpdateSelfEmailResponse: """ Updates the email address of the currently authenticated user. The change is persisted to the database immediately. Required permission: UPDATE_SELF_EMAIL Error cases: - PERMISSION_DENIED: User lacks UPDATE_SELF_EMAIL permission - INTERNAL: Server error while updating (e.g., user not found in database) """ return await self.execute_unary( request=request, method=MethodInfo( name="UpdateSelfEmail", service_name="soulfire.v1.ClientService", input=UpdateSelfEmailRequest, output=UpdateSelfEmailResponse, idempotency_level=IdempotencyLevel.UNKNOWN, stream_type=StreamType.UNARY, ), headers=headers, timeout_ms=timeout_ms, )
[docs] async def invalidate_self_sessions( self, request: InvalidateSelfSessionsRequest, *, headers: Headers | Mapping[str, str] | None = None, timeout_ms: int | None = None, ) -> InvalidateSelfSessionsResponse: """ Invalidates all existing sessions for the currently authenticated user. This is done by setting the user's minIssuedAt timestamp to the current time, which causes all previously issued JWT tokens to become invalid. After calling this method, the user will need to re-authenticate on all devices. Required permission: INVALIDATE_SELF_SESSIONS Error cases: - PERMISSION_DENIED: User lacks INVALIDATE_SELF_SESSIONS permission - INTERNAL: Server error while invalidating sessions (e.g., user not found) """ return await self.execute_unary( request=request, method=MethodInfo( name="InvalidateSelfSessions", service_name="soulfire.v1.ClientService", input=InvalidateSelfSessionsRequest, output=InvalidateSelfSessionsResponse, idempotency_level=IdempotencyLevel.UNKNOWN, stream_type=StreamType.UNARY, ), headers=headers, timeout_ms=timeout_ms, )
[docs] class ClientServiceSync(Protocol): """ Service for managing client/user-specific operations. All methods in this service operate on the currently authenticated user, identified via the JWT token in the Authorization header. Each method requires a specific GlobalPermission to be granted to the user. """
[docs] def get_client_data(self, request: ClientDataRequest, ctx: RequestContext[ClientDataRequest, ClientDataResponse], /) -> ClientDataResponse: """ Retrieves comprehensive data about the authenticated client and the server. Returns user profile information, granted permissions, and server metadata. Required permission: READ_CLIENT_DATA Error cases: - PERMISSION_DENIED: User lacks READ_CLIENT_DATA permission - INTERNAL: Server error while fetching client data """ raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs] def generate_web_dav_token(self, request: GenerateWebDAVTokenRequest, ctx: RequestContext[GenerateWebDAVTokenRequest, GenerateWebDAVTokenResponse], /) -> GenerateWebDAVTokenResponse: """ Generates a new JWT token specifically for WebDAV authentication. The generated token has the "webdav" audience and can only be used for WebDAV access. Required permission: GENERATE_SELF_WEBDAV_TOKEN Error cases: - PERMISSION_DENIED: User lacks GENERATE_SELF_WEBDAV_TOKEN permission - INTERNAL: Server error while generating token (e.g., user not found) """ raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs] def generate_api_token(self, request: GenerateAPITokenRequest, ctx: RequestContext[GenerateAPITokenRequest, GenerateAPITokenResponse], /) -> GenerateAPITokenResponse: """ Generates a new JWT token for API authentication. The generated token has the "api" audience and can be used for gRPC/HTTP API calls. Required permission: GENERATE_SELF_API_TOKEN Error cases: - PERMISSION_DENIED: User lacks GENERATE_SELF_API_TOKEN permission - INTERNAL: Server error while generating token (e.g., user not found) """ raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs] def update_self_username(self, request: UpdateSelfUsernameRequest, ctx: RequestContext[UpdateSelfUsernameRequest, UpdateSelfUsernameResponse], /) -> UpdateSelfUsernameResponse: """ Updates the username of the currently authenticated user. The change is persisted to the database immediately. Required permission: UPDATE_SELF_USERNAME Error cases: - PERMISSION_DENIED: User lacks UPDATE_SELF_USERNAME permission - INTERNAL: Server error while updating (e.g., user not found in database) """ raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs] def update_self_email(self, request: UpdateSelfEmailRequest, ctx: RequestContext[UpdateSelfEmailRequest, UpdateSelfEmailResponse], /) -> UpdateSelfEmailResponse: """ Updates the email address of the currently authenticated user. The change is persisted to the database immediately. Required permission: UPDATE_SELF_EMAIL Error cases: - PERMISSION_DENIED: User lacks UPDATE_SELF_EMAIL permission - INTERNAL: Server error while updating (e.g., user not found in database) """ raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs] def invalidate_self_sessions(self, request: InvalidateSelfSessionsRequest, ctx: RequestContext[InvalidateSelfSessionsRequest, InvalidateSelfSessionsResponse], /) -> InvalidateSelfSessionsResponse: """ Invalidates all existing sessions for the currently authenticated user. This is done by setting the user's minIssuedAt timestamp to the current time, which causes all previously issued JWT tokens to become invalid. After calling this method, the user will need to re-authenticate on all devices. Required permission: INVALIDATE_SELF_SESSIONS Error cases: - PERMISSION_DENIED: User lacks INVALIDATE_SELF_SESSIONS permission - INTERNAL: Server error while invalidating sessions (e.g., user not found) """ raise ConnectError(Code.UNIMPLEMENTED, 'Not implemented')
[docs] class ClientServiceWSGIApplication(ConnectWSGIApplication): def __init__( self, service: ClientServiceSync, 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.ClientService/GetClientData": EndpointSync.unary( method=MethodInfo( name="GetClientData", service_name="soulfire.v1.ClientService", input=ClientDataRequest, output=ClientDataResponse, idempotency_level=IdempotencyLevel.UNKNOWN, stream_type=StreamType.UNARY, ), function=service.get_client_data, ), "/soulfire.v1.ClientService/GenerateWebDAVToken": EndpointSync.unary( method=MethodInfo( name="GenerateWebDAVToken", service_name="soulfire.v1.ClientService", input=GenerateWebDAVTokenRequest, output=GenerateWebDAVTokenResponse, idempotency_level=IdempotencyLevel.UNKNOWN, stream_type=StreamType.UNARY, ), function=service.generate_web_dav_token, ), "/soulfire.v1.ClientService/GenerateAPIToken": EndpointSync.unary( method=MethodInfo( name="GenerateAPIToken", service_name="soulfire.v1.ClientService", input=GenerateAPITokenRequest, output=GenerateAPITokenResponse, idempotency_level=IdempotencyLevel.UNKNOWN, stream_type=StreamType.UNARY, ), function=service.generate_api_token, ), "/soulfire.v1.ClientService/UpdateSelfUsername": EndpointSync.unary( method=MethodInfo( name="UpdateSelfUsername", service_name="soulfire.v1.ClientService", input=UpdateSelfUsernameRequest, output=UpdateSelfUsernameResponse, idempotency_level=IdempotencyLevel.UNKNOWN, stream_type=StreamType.UNARY, ), function=service.update_self_username, ), "/soulfire.v1.ClientService/UpdateSelfEmail": EndpointSync.unary( method=MethodInfo( name="UpdateSelfEmail", service_name="soulfire.v1.ClientService", input=UpdateSelfEmailRequest, output=UpdateSelfEmailResponse, idempotency_level=IdempotencyLevel.UNKNOWN, stream_type=StreamType.UNARY, ), function=service.update_self_email, ), "/soulfire.v1.ClientService/InvalidateSelfSessions": EndpointSync.unary( method=MethodInfo( name="InvalidateSelfSessions", service_name="soulfire.v1.ClientService", input=InvalidateSelfSessionsRequest, output=InvalidateSelfSessionsResponse, idempotency_level=IdempotencyLevel.UNKNOWN, stream_type=StreamType.UNARY, ), function=service.invalidate_self_sessions, ), }, 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.ClientService"
[docs] class ClientServiceClientSync(ConnectClientSync): """ Service for managing client/user-specific operations. All methods in this service operate on the currently authenticated user, identified via the JWT token in the Authorization header. Each method requires a specific GlobalPermission to be granted to the user. """ 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 get_client_data( self, request: ClientDataRequest, *, headers: Headers | Mapping[str, str] | None = None, timeout_ms: int | None = None, ) -> ClientDataResponse: """ Retrieves comprehensive data about the authenticated client and the server. Returns user profile information, granted permissions, and server metadata. Required permission: READ_CLIENT_DATA Error cases: - PERMISSION_DENIED: User lacks READ_CLIENT_DATA permission - INTERNAL: Server error while fetching client data """ return self.execute_unary( request=request, method=MethodInfo( name="GetClientData", service_name="soulfire.v1.ClientService", input=ClientDataRequest, output=ClientDataResponse, idempotency_level=IdempotencyLevel.UNKNOWN, stream_type=StreamType.UNARY, ), headers=headers, timeout_ms=timeout_ms, )
[docs] def generate_web_dav_token( self, request: GenerateWebDAVTokenRequest, *, headers: Headers | Mapping[str, str] | None = None, timeout_ms: int | None = None, ) -> GenerateWebDAVTokenResponse: """ Generates a new JWT token specifically for WebDAV authentication. The generated token has the "webdav" audience and can only be used for WebDAV access. Required permission: GENERATE_SELF_WEBDAV_TOKEN Error cases: - PERMISSION_DENIED: User lacks GENERATE_SELF_WEBDAV_TOKEN permission - INTERNAL: Server error while generating token (e.g., user not found) """ return self.execute_unary( request=request, method=MethodInfo( name="GenerateWebDAVToken", service_name="soulfire.v1.ClientService", input=GenerateWebDAVTokenRequest, output=GenerateWebDAVTokenResponse, idempotency_level=IdempotencyLevel.UNKNOWN, stream_type=StreamType.UNARY, ), headers=headers, timeout_ms=timeout_ms, )
[docs] def generate_api_token( self, request: GenerateAPITokenRequest, *, headers: Headers | Mapping[str, str] | None = None, timeout_ms: int | None = None, ) -> GenerateAPITokenResponse: """ Generates a new JWT token for API authentication. The generated token has the "api" audience and can be used for gRPC/HTTP API calls. Required permission: GENERATE_SELF_API_TOKEN Error cases: - PERMISSION_DENIED: User lacks GENERATE_SELF_API_TOKEN permission - INTERNAL: Server error while generating token (e.g., user not found) """ return self.execute_unary( request=request, method=MethodInfo( name="GenerateAPIToken", service_name="soulfire.v1.ClientService", input=GenerateAPITokenRequest, output=GenerateAPITokenResponse, idempotency_level=IdempotencyLevel.UNKNOWN, stream_type=StreamType.UNARY, ), headers=headers, timeout_ms=timeout_ms, )
[docs] def update_self_username( self, request: UpdateSelfUsernameRequest, *, headers: Headers | Mapping[str, str] | None = None, timeout_ms: int | None = None, ) -> UpdateSelfUsernameResponse: """ Updates the username of the currently authenticated user. The change is persisted to the database immediately. Required permission: UPDATE_SELF_USERNAME Error cases: - PERMISSION_DENIED: User lacks UPDATE_SELF_USERNAME permission - INTERNAL: Server error while updating (e.g., user not found in database) """ return self.execute_unary( request=request, method=MethodInfo( name="UpdateSelfUsername", service_name="soulfire.v1.ClientService", input=UpdateSelfUsernameRequest, output=UpdateSelfUsernameResponse, idempotency_level=IdempotencyLevel.UNKNOWN, stream_type=StreamType.UNARY, ), headers=headers, timeout_ms=timeout_ms, )
[docs] def update_self_email( self, request: UpdateSelfEmailRequest, *, headers: Headers | Mapping[str, str] | None = None, timeout_ms: int | None = None, ) -> UpdateSelfEmailResponse: """ Updates the email address of the currently authenticated user. The change is persisted to the database immediately. Required permission: UPDATE_SELF_EMAIL Error cases: - PERMISSION_DENIED: User lacks UPDATE_SELF_EMAIL permission - INTERNAL: Server error while updating (e.g., user not found in database) """ return self.execute_unary( request=request, method=MethodInfo( name="UpdateSelfEmail", service_name="soulfire.v1.ClientService", input=UpdateSelfEmailRequest, output=UpdateSelfEmailResponse, idempotency_level=IdempotencyLevel.UNKNOWN, stream_type=StreamType.UNARY, ), headers=headers, timeout_ms=timeout_ms, )
[docs] def invalidate_self_sessions( self, request: InvalidateSelfSessionsRequest, *, headers: Headers | Mapping[str, str] | None = None, timeout_ms: int | None = None, ) -> InvalidateSelfSessionsResponse: """ Invalidates all existing sessions for the currently authenticated user. This is done by setting the user's minIssuedAt timestamp to the current time, which causes all previously issued JWT tokens to become invalid. After calling this method, the user will need to re-authenticate on all devices. Required permission: INVALIDATE_SELF_SESSIONS Error cases: - PERMISSION_DENIED: User lacks INVALIDATE_SELF_SESSIONS permission - INTERNAL: Server error while invalidating sessions (e.g., user not found) """ return self.execute_unary( request=request, method=MethodInfo( name="InvalidateSelfSessions", service_name="soulfire.v1.ClientService", input=InvalidateSelfSessionsRequest, output=InvalidateSelfSessionsResponse, idempotency_level=IdempotencyLevel.UNKNOWN, stream_type=StreamType.UNARY, ), headers=headers, timeout_ms=timeout_ms, )