usos-api 0.3.1__tar.gz → 0.3.2__tar.gz
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.
- {usos_api-0.3.1 → usos_api-0.3.2}/PKG-INFO +1 -1
- {usos_api-0.3.1 → usos_api-0.3.2}/pyproject.toml +1 -1
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/auth.py +10 -2
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/client.py +7 -2
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/connection.py +11 -3
- {usos_api-0.3.1 → usos_api-0.3.2}/README.md +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/__init__.py +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/exceptions.py +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/helper.py +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/logger.py +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/models/__init__.py +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/models/api_documentation.py +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/models/consumer.py +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/models/course.py +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/models/grade.py +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/models/group.py +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/models/lang_dict.py +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/models/programme.py +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/models/registration.py +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/models/term.py +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/models/user.py +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/services/__init__.py +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/services/api_documentation.py +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/services/api_server.py +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/services/courses.py +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/services/grades.py +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/services/groups.py +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/services/registrations.py +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/services/terms.py +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/services/users.py +0 -0
- {usos_api-0.3.1 → usos_api-0.3.2}/usos_api/utils/__init__.py +0 -0
|
@@ -21,13 +21,20 @@ class AuthManager:
|
|
|
21
21
|
# List of available scopes can be found at https://apps.usos.edu.pl/developers/api/authorization/#scopes
|
|
22
22
|
SCOPES = "|".join(["offline_access", "studies"])
|
|
23
23
|
|
|
24
|
-
def __init__(
|
|
24
|
+
def __init__(
|
|
25
|
+
self,
|
|
26
|
+
api_base_address: str,
|
|
27
|
+
consumer_key: str,
|
|
28
|
+
consumer_secret: str,
|
|
29
|
+
trust_env: bool = False,
|
|
30
|
+
):
|
|
25
31
|
"""
|
|
26
32
|
Initialize the authentication manager.
|
|
27
33
|
|
|
28
34
|
:param api_base_address: The base address of the USOS API.
|
|
29
35
|
:param consumer_key: Consumer key obtained from the USOS API.
|
|
30
36
|
:param consumer_secret: Consumer secret obtained from the USOS API.
|
|
37
|
+
:param trust_env: Whether to trust the environment variables for the connection, see https://docs.aiohttp.org/en/stable/client_reference.html#aiohttp.ClientSession for more information.
|
|
31
38
|
"""
|
|
32
39
|
self.base_address = api_base_address.rstrip("/") + "/"
|
|
33
40
|
self.consumer_key = consumer_key
|
|
@@ -35,6 +42,7 @@ class AuthManager:
|
|
|
35
42
|
self.access_token = None
|
|
36
43
|
self.access_token_secret = None
|
|
37
44
|
self._session = None
|
|
45
|
+
self.trust_env = trust_env
|
|
38
46
|
self._oauth_client = Client(consumer_key, consumer_secret)
|
|
39
47
|
|
|
40
48
|
async def __aenter__(self) -> "AuthManager":
|
|
@@ -60,7 +68,7 @@ class AuthManager:
|
|
|
60
68
|
"""
|
|
61
69
|
Open the manager.
|
|
62
70
|
"""
|
|
63
|
-
self._session = aiohttp.ClientSession()
|
|
71
|
+
self._session = aiohttp.ClientSession(trust_env=self.trust_env)
|
|
64
72
|
|
|
65
73
|
async def close(self):
|
|
66
74
|
"""
|
|
@@ -34,7 +34,11 @@ class USOSClient:
|
|
|
34
34
|
"""
|
|
35
35
|
|
|
36
36
|
def __init__(
|
|
37
|
-
self,
|
|
37
|
+
self,
|
|
38
|
+
api_base_address: str,
|
|
39
|
+
consumer_key: str,
|
|
40
|
+
consumer_secret: str,
|
|
41
|
+
trust_env: bool = False,
|
|
38
42
|
) -> None:
|
|
39
43
|
"""
|
|
40
44
|
Initialize the USOS API client.
|
|
@@ -42,9 +46,10 @@ class USOSClient:
|
|
|
42
46
|
:param api_base_address: The base address of the USOS API.
|
|
43
47
|
:param consumer_key: Consumer key obtained from the USOS API.
|
|
44
48
|
:param consumer_secret: Consumer secret obtained from the USOS API.
|
|
49
|
+
:param trust_env: Whether to trust the environment variables for the connection, see https://docs.aiohttp.org/en/stable/client_reference.html#aiohttp.ClientSession for more information.
|
|
45
50
|
"""
|
|
46
51
|
self.connection = USOSAPIConnection(
|
|
47
|
-
api_base_address, consumer_key, consumer_secret
|
|
52
|
+
api_base_address, consumer_key, consumer_secret, trust_env
|
|
48
53
|
)
|
|
49
54
|
self.user_service = UserService(self.connection)
|
|
50
55
|
self.group_service = GroupService(self.connection)
|
|
@@ -15,19 +15,27 @@ class USOSAPIConnection:
|
|
|
15
15
|
A connection to the USOS API.
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
|
-
def __init__(
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
api_base_address: str,
|
|
21
|
+
consumer_key: str,
|
|
22
|
+
consumer_secret: str,
|
|
23
|
+
trust_env: bool = False,
|
|
24
|
+
):
|
|
19
25
|
"""
|
|
20
26
|
Initialize the USOS API connection.
|
|
21
27
|
|
|
22
28
|
:param api_base_address: The base address of the USOS API.
|
|
23
29
|
:param consumer_key: Consumer key obtained from the USOS API.
|
|
24
30
|
:param consumer_secret: Consumer secret obtained from the USOS API.
|
|
31
|
+
:param trust_env: Whether to trust the environment variables for the connection, see https://docs.aiohttp.org/en/stable/client_reference.html#aiohttp.ClientSession for more information.
|
|
25
32
|
"""
|
|
26
33
|
self.base_address = api_base_address.rstrip("/") + "/"
|
|
27
34
|
self.auth_manager = AuthManager(
|
|
28
|
-
self.base_address, consumer_key, consumer_secret
|
|
35
|
+
self.base_address, consumer_key, consumer_secret, trust_env
|
|
29
36
|
)
|
|
30
37
|
self._session = None
|
|
38
|
+
self.trust_env = trust_env
|
|
31
39
|
|
|
32
40
|
async def __aenter__(self) -> "USOSAPIConnection":
|
|
33
41
|
"""
|
|
@@ -52,7 +60,7 @@ class USOSAPIConnection:
|
|
|
52
60
|
"""
|
|
53
61
|
Open the connection.
|
|
54
62
|
"""
|
|
55
|
-
self._session = aiohttp.ClientSession()
|
|
63
|
+
self._session = aiohttp.ClientSession(trust_env=self.trust_env)
|
|
56
64
|
await self.auth_manager.open()
|
|
57
65
|
|
|
58
66
|
async def close(self):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|