seer-pas-sdk 0.1.1__py3-none-any.whl → 0.1.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- seer_pas_sdk/auth/__init__.py +1 -77
- seer_pas_sdk/auth/auth.py +77 -0
- seer_pas_sdk/core/__init__.py +1 -1307
- seer_pas_sdk/core/sdk.py +1250 -0
- seer_pas_sdk/objects/__init__.py +1 -129
- seer_pas_sdk/objects/platemap.py +129 -0
- {seer_pas_sdk-0.1.1.dist-info → seer_pas_sdk-0.1.3.dist-info}/METADATA +2 -2
- seer_pas_sdk-0.1.3.dist-info/RECORD +19 -0
- seer_pas_sdk-0.1.1.dist-info/RECORD +0 -16
- {seer_pas_sdk-0.1.1.dist-info → seer_pas_sdk-0.1.3.dist-info}/LICENSE.txt +0 -0
- {seer_pas_sdk-0.1.1.dist-info → seer_pas_sdk-0.1.3.dist-info}/WHEEL +0 -0
- {seer_pas_sdk-0.1.1.dist-info → seer_pas_sdk-0.1.3.dist-info}/top_level.txt +0 -0
seer_pas_sdk/auth/__init__.py
CHANGED
|
@@ -1,77 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class Auth:
|
|
5
|
-
_instances = {
|
|
6
|
-
"US": "https://api.pas.seer.software/",
|
|
7
|
-
"EU": "https://api.pas-eu.seer.bio/",
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
def __init__(self, username, password, instance="US"):
|
|
11
|
-
"""
|
|
12
|
-
Constructor for the Auth class. Uses the username, password and instance name to instantiate the class.
|
|
13
|
-
|
|
14
|
-
Parameters
|
|
15
|
-
----------
|
|
16
|
-
username: str
|
|
17
|
-
The username of the account associated with the PAS instance.
|
|
18
|
-
password: str
|
|
19
|
-
The password of the account associated with the PAS instance.
|
|
20
|
-
instance: str
|
|
21
|
-
The instance name of the PAS instance (`US | EU`). Defaults to `US`.
|
|
22
|
-
"""
|
|
23
|
-
|
|
24
|
-
self.username = username
|
|
25
|
-
self.__password = password
|
|
26
|
-
|
|
27
|
-
if instance not in Auth._instances:
|
|
28
|
-
if instance.startswith("https://"):
|
|
29
|
-
# Support arbitrary endpoint for testing
|
|
30
|
-
self.url = instance
|
|
31
|
-
else:
|
|
32
|
-
raise ValueError("Invalid PAS instance.")
|
|
33
|
-
else:
|
|
34
|
-
self.url = Auth._instances[instance]
|
|
35
|
-
|
|
36
|
-
self.instance = instance
|
|
37
|
-
|
|
38
|
-
def login(self):
|
|
39
|
-
"""
|
|
40
|
-
Logs into the PAS instance using the mapped URL and the login credentials (username and password) provided in the constructor.
|
|
41
|
-
|
|
42
|
-
Returns
|
|
43
|
-
-------
|
|
44
|
-
dict
|
|
45
|
-
A dictionary containing the login response from the PAS instance.
|
|
46
|
-
"""
|
|
47
|
-
response = requests.post(
|
|
48
|
-
f"{self.url}auth/login",
|
|
49
|
-
json={"username": self.username, "password": self.__password},
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
if not response:
|
|
53
|
-
raise ValueError(
|
|
54
|
-
"Check if the credentials are correct or if the backend is running or not."
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
if response.status_code == 200:
|
|
58
|
-
return response.json()
|
|
59
|
-
|
|
60
|
-
def get_token(self):
|
|
61
|
-
"""
|
|
62
|
-
Gets the token from the login response.
|
|
63
|
-
|
|
64
|
-
Returns
|
|
65
|
-
-------
|
|
66
|
-
str
|
|
67
|
-
The token from the login response.
|
|
68
|
-
"""
|
|
69
|
-
|
|
70
|
-
res = self.login()
|
|
71
|
-
|
|
72
|
-
if "id_token" not in res or "access_token" not in res:
|
|
73
|
-
raise ValueError(
|
|
74
|
-
"Check if the credentials are correct or if the backend is running or not."
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
return res["id_token"], res["access_token"]
|
|
1
|
+
from .auth import Auth
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Auth:
|
|
5
|
+
_instances = {
|
|
6
|
+
"US": "https://api.pas.seer.software/",
|
|
7
|
+
"EU": "https://api.pas-eu.seer.bio/",
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
def __init__(self, username, password, instance="US"):
|
|
11
|
+
"""
|
|
12
|
+
Constructor for the Auth class. Uses the username, password and instance name to instantiate the class.
|
|
13
|
+
|
|
14
|
+
Parameters
|
|
15
|
+
----------
|
|
16
|
+
username: str
|
|
17
|
+
The username of the account associated with the PAS instance.
|
|
18
|
+
password: str
|
|
19
|
+
The password of the account associated with the PAS instance.
|
|
20
|
+
instance: str
|
|
21
|
+
The instance name of the PAS instance (`US | EU`). Defaults to `US`.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
self.username = username
|
|
25
|
+
self.__password = password
|
|
26
|
+
|
|
27
|
+
if instance not in Auth._instances:
|
|
28
|
+
if instance.startswith("https://"):
|
|
29
|
+
# Support arbitrary endpoint for testing
|
|
30
|
+
self.url = instance
|
|
31
|
+
else:
|
|
32
|
+
raise ValueError("Invalid PAS instance.")
|
|
33
|
+
else:
|
|
34
|
+
self.url = Auth._instances[instance]
|
|
35
|
+
|
|
36
|
+
self.instance = instance
|
|
37
|
+
|
|
38
|
+
def login(self):
|
|
39
|
+
"""
|
|
40
|
+
Logs into the PAS instance using the mapped URL and the login credentials (username and password) provided in the constructor.
|
|
41
|
+
|
|
42
|
+
Returns
|
|
43
|
+
-------
|
|
44
|
+
dict
|
|
45
|
+
A dictionary containing the login response from the PAS instance.
|
|
46
|
+
"""
|
|
47
|
+
response = requests.post(
|
|
48
|
+
f"{self.url}auth/login",
|
|
49
|
+
json={"username": self.username, "password": self.__password},
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
if not response:
|
|
53
|
+
raise ValueError(
|
|
54
|
+
"Check if the credentials are correct or if the backend is running or not."
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
if response.status_code == 200:
|
|
58
|
+
return response.json()
|
|
59
|
+
|
|
60
|
+
def get_token(self):
|
|
61
|
+
"""
|
|
62
|
+
Gets the token from the login response.
|
|
63
|
+
|
|
64
|
+
Returns
|
|
65
|
+
-------
|
|
66
|
+
str
|
|
67
|
+
The token from the login response.
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
res = self.login()
|
|
71
|
+
|
|
72
|
+
if "id_token" not in res or "access_token" not in res:
|
|
73
|
+
raise ValueError(
|
|
74
|
+
"Check if the credentials are correct or if the backend is running or not."
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
return res["id_token"], res["access_token"]
|