-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathclient.py
More file actions
52 lines (41 loc) · 1.48 KB
/
client.py
File metadata and controls
52 lines (41 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Code generated by op-codegen - DO NO EDIT MANUALLY
from __future__ import annotations
import weakref
from .core import UniffiCore, InnerClient
from .desktop_core import DesktopCore
from .defaults import new_default_config, DesktopAuth
from .secrets import Secrets
from .items import Items
from .vaults import Vaults
from .groups import Groups
class Client:
secrets: Secrets
items: Items
vaults: Vaults
groups: Groups
@classmethod
async def authenticate(
cls, auth: str | DesktopAuth,
integration_name: str, integration_version: str,
shared_library_path: str = ""
) -> Client:
config = new_default_config(
auth=auth,
integration_name=integration_name,
integration_version=integration_version,
)
if isinstance(auth, DesktopAuth):
core = DesktopCore(auth.account_name, shared_library_path)
else:
core = UniffiCore()
client_id = int(await core.init_client(config))
inner_client = InnerClient(client_id, core, config)
authenticated_client = cls()
authenticated_client.secrets = Secrets(inner_client)
authenticated_client.items = Items(inner_client)
authenticated_client.vaults = Vaults(inner_client)
authenticated_client.groups = Groups(inner_client)
authenticated_client._finalizer = weakref.finalize(
cls, core.release_client, client_id
)
return authenticated_client