/
__init__.py
43 lines (31 loc) · 1.37 KB
/
__init__.py
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
"""Basic entry points."""
__all__ = ["connect", "login"]
from .utils.maas_async import asynchronous
@asynchronous
async def connect(url, *, apikey=None, insecure=False):
"""Connect to MAAS at `url` using a previously obtained API key.
:param url: The URL of MAAS, e.g. http://maas.example.com:5240/MAAS/
:param apikey: The API key to use, e.g.
SkTvsyHhzkREvvdtNk:Ywn5FvXVupVPvNUhrN:cm3Q2f5naXYPYsrPDPfQy9Q9cUFaEgbM
:param insecure: Whether to check TLS certificates when using HTTPS.
:return: A client object.
"""
from .facade import Client # Lazy.
from .viscera import Origin # Lazy.
profile, origin = await Origin.connect(url, apikey=apikey, insecure=insecure)
return Client(origin)
@asynchronous
async def login(url, *, username=None, password=None, insecure=False):
"""Connect to MAAS at `url` with a user name and password.
:param url: The URL of MAAS, e.g. http://maas.example.com:5240/MAAS/
:param username: The user name to use, e.g. fred.
:param password: The user's password.
:param insecure: Whether to check TLS certificates when using HTTPS.
:return: A client object.
"""
from .facade import Client # Lazy.
from .viscera import Origin # Lazy.
profile, origin = await Origin.login(
url, username=username, password=password, insecure=insecure
)
return Client(origin)