Skip to content

Commit ef92d17

Browse files
committed
Remove parameters from login method
1 parent 2313838 commit ef92d17

File tree

15 files changed

+156
-147
lines changed

15 files changed

+156
-147
lines changed

DEV.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2+
To bump the version, add a tag, and push, run
3+
```bash
4+
python bump_version.py patch --tag --push
5+
```
6+
If bumping a minor or major version, replace `patch` with `minor` or `major`
7+
18
To bump the version by a patch, run:
29
```bash
310
poetry version patch

manual_tests/test_manual_access_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from aiohttp import ClientSession
22
from environs import Env
33

4-
from pdap_access_manager.access_manager import AccessManager
4+
from pdap_access_manager.src.access_manager import AccessManager
55
from pdap_access_manager import RequestType, DataSourcesNamespaces, RequestInfo
66

77

pdap_access_manager/__init__.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +0,0 @@
1-
from pdap_access_manager.access_manager import AccessManager
2-
from pdap_access_manager.request import RequestInfo
3-
from pdap_access_manager.response import ResponseInfo
4-
from pdap_access_manager.enums import RequestType, DataSourcesNamespaces, SourceCollectorNamespaces
5-
6-
__all__ = [
7-
"AccessManager"
8-
]
Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
from contextlib import asynccontextmanager
22
from http import HTTPStatus
3-
from typing import Optional
3+
from typing import Optional, Any, AsyncGenerator
44

55
from aiohttp import ClientSession, ClientResponseError
66

7-
from pdap_access_manager import RequestType, DataSourcesNamespaces, SourceCollectorNamespaces, ResponseInfo, RequestInfo
8-
from pdap_access_manager.constants import DEFAULT_DATA_SOURCES_URL, DEFAULT_SOURCE_COLLECTOR_URL
7+
from pdap_access_manager.src.constants import DEFAULT_DATA_SOURCES_URL, DEFAULT_SOURCE_COLLECTOR_URL
8+
from pdap_access_manager.src.enums import RequestType, DataSourcesNamespaces, SourceCollectorNamespaces
9+
from pdap_access_manager.src.models.request import RequestInfo
10+
from pdap_access_manager.src.models.response import ResponseInfo
911

1012
request_methods = {
1113
RequestType.POST: ClientSession.post,
@@ -45,7 +47,7 @@ def __init__(
4547
self.source_collector_url = source_collector_url
4648

4749
@asynccontextmanager
48-
async def with_session(self) -> "AccessManager":
50+
async def with_session(self) -> AsyncGenerator["AccessManager", Any]:
4951
"""Allows just the session lifecycle to be managed."""
5052
created_session = False
5153
if self.session is None:
@@ -102,10 +104,7 @@ async def access_token(self) -> str:
102104
:return:
103105
"""
104106
if self._access_token is None:
105-
await self.login(
106-
email=self.email,
107-
password=self.password
108-
)
107+
await self.login()
109108
return self._access_token
110109

111110
@property
@@ -115,10 +114,7 @@ async def refresh_token(self) -> str:
115114
:return:
116115
"""
117116
if self._refresh_token is None:
118-
await self.login(
119-
email=self.email,
120-
password=self.password
121-
)
117+
await self.login()
122118
return self._refresh_token
123119

124120
async def load_api_key(self):
@@ -159,7 +155,7 @@ async def refresh_access_token(self):
159155
self._refresh_token = data['refresh_token']
160156
except ClientResponseError as e:
161157
if e.status == HTTPStatus.UNAUTHORIZED: # Token expired, retry logging in
162-
await self.login(self.email, self.password)
158+
await self.login()
163159

164160
async def make_request(self, ri: RequestInfo, allow_retry: bool = True) -> ResponseInfo:
165161
"""
@@ -187,11 +183,9 @@ async def make_request(self, ri: RequestInfo, allow_retry: bool = True) -> Respo
187183
raise e
188184

189185

190-
async def login(self, email: str, password: str):
186+
async def login(self) -> None:
191187
"""
192188
Login to PDAP and retrieve access and refresh tokens
193-
:param email:
194-
:param password:
195189
:return:
196190
"""
197191
url = self.build_url(
@@ -202,8 +196,8 @@ async def login(self, email: str, password: str):
202196
type_=RequestType.POST,
203197
url=url,
204198
json_={
205-
"email": email,
206-
"password": password
199+
"email": self.email,
200+
"password": self.password
207201
}
208202
)
209203
response_info = await self.make_request(request_info)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from enum import Enum
22

33

4-
class RequestType(Enum):
4+
class RequestType(str, Enum):
55
POST = "POST"
66
PUT = "PUT"
77
GET = "GET"

pdap_access_manager/src/models/__init__.py

Whitespace-only changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from boltons import urlutils
44
from pydantic import BaseModel
55

6-
from pdap_access_manager import RequestType
6+
from enums import RequestType
77

88

99
class RequestInfo(BaseModel):
File renamed without changes.

0 commit comments

Comments
 (0)