Module neuroio.auth.v1
None
None
View Source
from httpx import Response
from neuroio.base import IAMBase, IAMBaseAsync, IAMBaseBase
class AuthBase(IAMBaseBase):
def get_url(self, key: str) -> str:
return self.base_url + f"/v1/auth/{key}/"
class Impl(IAMBase, AuthBase):
def login(self, username: str, password: str) -> Response:
data = {"username": username, "password": password}
with self.get_client() as client:
return client.post(url=self.get_url("token"), json=data)
def password_change(
self, old_password: str, new_password: str, reset_tokens: bool = False
) -> Response:
data = {
"old_password": old_password,
"password": new_password,
"password2": new_password,
"reset_tokens": reset_tokens,
}
with self.get_client() as client:
return client.post(url=self.get_url("password/change"), json=data)
class ImplAsync(IAMBaseAsync, AuthBase):
async def login(self, username: str, password: str) -> Response:
data = {"username": username, "password": password}
async with self.get_client() as client:
return await client.post(url=self.get_url("token"), json=data)
async def password_change(
self, old_password: str, new_password: str, reset_tokens: bool = False
) -> Response:
data = {
"old_password": old_password,
"password": new_password,
"password2": new_password,
"reset_tokens": reset_tokens,
}
async with self.get_client() as client:
return await client.post(
url=self.get_url("password/change"), json=data
)
Classes
AuthBase
class AuthBase(
/,
*args,
**kwargs
)
View Source
class AuthBase(IAMBaseBase):
def get_url(self, key: str) -> str:
return self.base_url + f"/v1/auth/{key}/"
Ancestors (in MRO)
- neuroio.base.IAMBaseBase
Descendants
- neuroio.auth.v1.Impl
- neuroio.auth.v1.ImplAsync
Class variables
base_url
Methods
get_url
def get_url(
self,
key: str
) -> str
View Source
def get_url(self, key: str) -> str:
return self.base_url + f"/v1/auth/{key}/"
Impl
class Impl(
settings: dict
)
View Source
class Impl(IAMBase, AuthBase):
def login(self, username: str, password: str) -> Response:
data = {"username": username, "password": password}
with self.get_client() as client:
return client.post(url=self.get_url("token"), json=data)
def password_change(
self, old_password: str, new_password: str, reset_tokens: bool = False
) -> Response:
data = {
"old_password": old_password,
"password": new_password,
"password2": new_password,
"reset_tokens": reset_tokens,
}
with self.get_client() as client:
return client.post(url=self.get_url("password/change"), json=data)
Ancestors (in MRO)
- neuroio.base.IAMBase
- abc.ABC
- neuroio.base.Base
- neuroio.auth.v1.AuthBase
- neuroio.base.IAMBaseBase
Class variables
base_url
Methods
get_client
def get_client(
self
) -> httpx.Client
View Source
def get_client(self) -> Client:
return Client(**self.settings)
get_url
def get_url(
self,
key: str
) -> str
View Source
def get_url(self, key: str) -> str:
return self.base_url + f"/v1/auth/{key}/"
login
def login(
self,
username: str,
password: str
) -> httpx.Response
View Source
def login(self, username: str, password: str) -> Response:
data = {"username": username, "password": password}
with self.get_client() as client:
return client.post(url=self.get_url("token"), json=data)
password_change
def password_change(
self,
old_password: str,
new_password: str,
reset_tokens: bool = False
) -> httpx.Response
View Source
def password_change(
self, old_password: str, new_password: str, reset_tokens: bool = False
) -> Response:
data = {
"old_password": old_password,
"password": new_password,
"password2": new_password,
"reset_tokens": reset_tokens,
}
with self.get_client() as client:
return client.post(url=self.get_url("password/change"), json=data)
ImplAsync
class ImplAsync(
settings: dict
)
View Source
class ImplAsync(IAMBaseAsync, AuthBase):
async def login(self, username: str, password: str) -> Response:
data = {"username": username, "password": password}
async with self.get_client() as client:
return await client.post(url=self.get_url("token"), json=data)
async def password_change(
self, old_password: str, new_password: str, reset_tokens: bool = False
) -> Response:
data = {
"old_password": old_password,
"password": new_password,
"password2": new_password,
"reset_tokens": reset_tokens,
}
async with self.get_client() as client:
return await client.post(
url=self.get_url("password/change"), json=data
)
Ancestors (in MRO)
- neuroio.base.IAMBaseAsync
- abc.ABC
- neuroio.base.Base
- neuroio.auth.v1.AuthBase
- neuroio.base.IAMBaseBase
Class variables
base_url
Methods
get_client
def get_client(
self
) -> httpx.AsyncClient
View Source
def get_client(self) -> AsyncClient:
return AsyncClient(**self.settings)
get_url
def get_url(
self,
key: str
) -> str
View Source
def get_url(self, key: str) -> str:
return self.base_url + f"/v1/auth/{key}/"
login
def login(
self,
username: str,
password: str
) -> httpx.Response
View Source
async def login(self, username: str, password: str) -> Response:
data = {"username": username, "password": password}
async with self.get_client() as client:
return await client.post(url=self.get_url("token"), json=data)
password_change
def password_change(
self,
old_password: str,
new_password: str,
reset_tokens: bool = False
) -> httpx.Response
View Source
async def password_change(
self, old_password: str, new_password: str, reset_tokens: bool = False
) -> Response:
data = {
"old_password": old_password,
"password": new_password,
"password2": new_password,
"reset_tokens": reset_tokens,
}
async with self.get_client() as client:
return await client.post(
url=self.get_url("password/change"), json=data
)