cleanup
This commit is contained in:
@ -44,3 +44,8 @@ class AuthClient:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class AuthError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
|
|
||||||
class AuthError(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
@ -1,16 +1,9 @@
|
|||||||
from .authclient import AuthClient, AUTH_HEADERS
|
from .authclient import AuthClient, AuthError, AUTH_HEADERS
|
||||||
from .autherror import AuthError
|
|
||||||
from .utils import post_request, get_request
|
from .utils import post_request, get_request
|
||||||
|
|
||||||
|
|
||||||
class SciCat(AuthClient):
|
class SciCat(AuthClient):
|
||||||
|
|
||||||
@property
|
|
||||||
def proposals(self):
|
|
||||||
url = self.address + "/proposals"
|
|
||||||
headers = self.auth_headers
|
|
||||||
return get_request(url, headers=headers)
|
|
||||||
|
|
||||||
def authenticate(self, username, password):
|
def authenticate(self, username, password):
|
||||||
url = self.address + "/users/login"
|
url = self.address + "/users/login"
|
||||||
auth_payload = {
|
auth_payload = {
|
||||||
@ -26,6 +19,13 @@ class SciCat(AuthClient):
|
|||||||
return token
|
return token
|
||||||
|
|
||||||
|
|
||||||
|
@property
|
||||||
|
def proposals(self):
|
||||||
|
url = self.address + "/proposals"
|
||||||
|
headers = self.auth_headers
|
||||||
|
return get_request(url, headers=headers)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SciCatAuthError(AuthError):
|
class SciCatAuthError(AuthError):
|
||||||
pass
|
pass
|
||||||
|
@ -1,24 +1,10 @@
|
|||||||
from .authclient import AuthClient, AUTH_HEADERS
|
from .authclient import AuthClient, AuthError, AUTH_HEADERS
|
||||||
from .autherror import AuthError
|
|
||||||
from .utils import post_request, get_request
|
from .utils import post_request, get_request
|
||||||
from .mkfilt import make_filter
|
from .mkfilt import make_filter
|
||||||
|
|
||||||
|
|
||||||
class SciLog(AuthClient):
|
class SciLog(AuthClient):
|
||||||
|
|
||||||
def get_snippets(self, **kwargs):
|
|
||||||
url = self.address + "/basesnippets"
|
|
||||||
params = make_filter(**kwargs)
|
|
||||||
headers = self.auth_headers
|
|
||||||
return get_request(url, params=params, headers=headers)
|
|
||||||
|
|
||||||
def post_snippet(self, **kwargs):
|
|
||||||
url = self.address + "/basesnippets"
|
|
||||||
payload = kwargs
|
|
||||||
headers = self.auth_headers
|
|
||||||
return post_request(url, payload=payload, headers=headers)
|
|
||||||
|
|
||||||
|
|
||||||
def authenticate(self, username, password):
|
def authenticate(self, username, password):
|
||||||
url = self.address + "/users/login"
|
url = self.address + "/users/login"
|
||||||
auth_payload = {
|
auth_payload = {
|
||||||
@ -34,6 +20,19 @@ class SciLog(AuthClient):
|
|||||||
return token
|
return token
|
||||||
|
|
||||||
|
|
||||||
|
def get_snippets(self, **kwargs):
|
||||||
|
url = self.address + "/basesnippets"
|
||||||
|
params = make_filter(**kwargs)
|
||||||
|
headers = self.auth_headers
|
||||||
|
return get_request(url, params=params, headers=headers)
|
||||||
|
|
||||||
|
def post_snippet(self, **kwargs):
|
||||||
|
url = self.address + "/basesnippets"
|
||||||
|
payload = kwargs
|
||||||
|
headers = self.auth_headers
|
||||||
|
return post_request(url, payload=payload, headers=headers)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SciLogAuthError(AuthError):
|
class SciLogAuthError(AuthError):
|
||||||
pass
|
pass
|
||||||
|
Reference in New Issue
Block a user