# Released under the MIT License. See LICENSE for details.#"""Functionality related to cloud functionality."""from__future__importannotationsfromenumimportEnumfromdataclassesimportdataclass,fieldfromtypingimportTYPE_CHECKING,Annotated,overridefromefro.messageimportMessage,Responsefromefro.dataclassioimportioprepped,IOAttrsfrombacommon.securedataimportSecureDataCheckerfrombacommon.transferimportDirectoryManifestfrombacommon.loginimportLoginTypeifTYPE_CHECKING:pass
[docs]classWebLocation(Enum):"""Set of places we can be directed on ballistica.net."""ACCOUNT_EDITOR='e'ACCOUNT_DELETE_SECTION='d'
[docs]@ioprepped@dataclassclassLoginProxyRequestMessage(Message):"""Request send to the cloud to ask for a login-proxy."""
[docs]@ioprepped@dataclassclassLoginProxyRequestResponse(Response):"""Response to a request for a login proxy."""# URL to direct the user to for sign in.url:str# URL to use for overlay-web-browser sign ins.url_overlay:str# Proxy-Login id for querying results.proxyid:str# Proxy-Login key for querying results.proxykey:str
[docs]@ioprepped@dataclassclassLoginProxyStateQueryMessage(Message):"""Soo.. how is that login proxy going?"""proxyid:strproxykey:str
[docs]@ioprepped@dataclassclassSendInfoResponse(Response):"""Response to sending into the server."""handled:boolmessage:str|None=Nonelegacy_code:str|None=None
[docs]@ioprepped@dataclassclassWorkspaceFetchState:"""Common state data for a workspace fetch."""manifest:DirectoryManifestiteration:int=0total_deletes:int=0total_downloads:int=0total_up_to_date:int|None=None
[docs]@ioprepped@dataclassclassWorkspaceFetchMessage(Message):"""Can I get some of that workspace action?"""workspaceid:strstate:WorkspaceFetchState
[docs]@ioprepped@dataclassclassWorkspaceFetchResponse(Response):"""Here's that workspace you asked for, boss."""state:WorkspaceFetchStatedeletes:list[str]=field(default_factory=list)downloads_inline:dict[str,bytes]=field(default_factory=dict)done:bool=False
[docs]@ioprepped@dataclassclassMerchAvailabilityMessage(Message):"""Can we show merch link?"""
[docs]@ioprepped@dataclassclassMerchAvailabilityResponse(Response):"""About that merch..."""url:str|None
[docs]@ioprepped@dataclassclassSignInMessage(Message):"""Can I sign in please?"""login_type:LoginTypesign_in_token:str# For debugging. Can remove soft_default once build 20988+ is ubiquitous.description:strapptime:float
[docs]@ioprepped@dataclassclassSignInResponse(Response):"""Here's that sign-in result you asked for, boss."""credentials:str|None
[docs]@ioprepped@dataclassclassManageAccountMessage(Message):"""Message asking for a manage-account url."""weblocation:WebLocation=(WebLocation.ACCOUNT_EDITOR)
[docs]@ioprepped@dataclassclassSecureDataCheckResponse(Response):"""Here's the result of that data check, boss."""# Whether the data signature was valid.result:bool
[docs]@ioprepped@dataclassclassSecureDataCheckerRequest(Message):"""Can I get a checker over here?."""
[docs]@ioprepped@dataclassclassSecureDataCheckerResponse(Response):"""Here's that checker ya asked for, boss."""checker:SecureDataChecker
# Docs-generation hack; import some stuff that we likely only forward-declared# in our actual source code so that docs tools can find it.fromtypingimport(Coroutine,Any,Literal,Callable,Generator,Awaitable,Sequence,Self)importasynciofromconcurrent.futuresimportFuture