import order and spaces
This commit is contained in:
@ -2,9 +2,9 @@ import requests
|
|||||||
import functools
|
import functools
|
||||||
import json
|
import json
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
from .authmixin import AuthMixin, AuthError, HEADER_JSON
|
from .authmixin import AuthMixin, AuthError, HEADER_JSON
|
||||||
|
|
||||||
|
|
||||||
def authenticated(func):
|
def authenticated(func):
|
||||||
@functools.wraps(func)
|
@functools.wraps(func)
|
||||||
def authenticated_call(*args, **kwargs):
|
def authenticated_call(*args, **kwargs):
|
||||||
@ -15,11 +15,12 @@ def authenticated(func):
|
|||||||
else:
|
else:
|
||||||
kwargs["headers"] = {}
|
kwargs["headers"] = {}
|
||||||
kwargs["headers"]["Authorization"] = args[0].token
|
kwargs["headers"]["Authorization"] = args[0].token
|
||||||
|
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
return authenticated_call
|
return authenticated_call
|
||||||
|
|
||||||
|
|
||||||
class HttpClient(AuthMixin):
|
class HttpClient(AuthMixin):
|
||||||
|
|
||||||
def __init__(self, address):
|
def __init__(self, address):
|
||||||
self.address = address
|
self.address = address
|
||||||
self._verify_certificate = True
|
self._verify_certificate = True
|
||||||
@ -48,7 +49,6 @@ class HttpClient(AuthMixin):
|
|||||||
self.config.delete()
|
self.config.delete()
|
||||||
raise response.raise_for_status()
|
raise response.raise_for_status()
|
||||||
|
|
||||||
|
|
||||||
@authenticated
|
@authenticated
|
||||||
def post_request(self, url, payload=None, headers=None, timeout=10):
|
def post_request(self, url, payload=None, headers=None, timeout=10):
|
||||||
response = requests.post(url, json=payload, headers=headers, timeout=timeout, verify=self._verify_certificate).json()
|
response = requests.post(url, json=payload, headers=headers, timeout=timeout, verify=self._verify_certificate).json()
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import functools
|
||||||
|
from typing import TypeVar, Union, List, Type, get_type_hints
|
||||||
|
|
||||||
from .authmixin import AuthMixin, AuthError, HEADER_JSON
|
from .authmixin import AuthMixin, AuthError, HEADER_JSON
|
||||||
from .httpclient import HttpClient
|
from .httpclient import HttpClient
|
||||||
from .snippet import Snippet, Basesnippet, Paragraph
|
from .snippet import Snippet, Basesnippet, Paragraph
|
||||||
from typing import TypeVar, Union, List, Type, get_type_hints
|
|
||||||
import functools
|
|
||||||
|
|
||||||
def pinned_to_logbook(logbook_keys):
|
def pinned_to_logbook(logbook_keys):
|
||||||
def pinned_to_logbook_inner(func):
|
def pinned_to_logbook_inner(func):
|
||||||
@ -23,6 +25,7 @@ def pinned_to_logbook(logbook_keys):
|
|||||||
return pinned_to_logbook_call
|
return pinned_to_logbook_call
|
||||||
return pinned_to_logbook_inner
|
return pinned_to_logbook_inner
|
||||||
|
|
||||||
|
|
||||||
class SciLogRestAPI(HttpClient):
|
class SciLogRestAPI(HttpClient):
|
||||||
def __init__(self, url):
|
def __init__(self, url):
|
||||||
super().__init__(url)
|
super().__init__(url)
|
||||||
|
@ -28,7 +28,6 @@ def property_maker(cls, name, type_name):
|
|||||||
return prop
|
return prop
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Snippet:
|
class Snippet:
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
@ -96,7 +95,6 @@ class Basesnippet(Snippet):
|
|||||||
self.snippetType = "basesnippet"
|
self.snippetType = "basesnippet"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Paragraph(Basesnippet):
|
class Paragraph(Basesnippet):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
Reference in New Issue
Block a user