mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-26 19:05:13 +00:00
style(vaults): fix formatting from #147
This commit is contained in:
+14
-10
@@ -10,7 +10,15 @@ from unshackle.core.vault import Vault
|
|||||||
class API(Vault):
|
class API(Vault):
|
||||||
"""Key Vault using a simple RESTful HTTP API call."""
|
"""Key Vault using a simple RESTful HTTP API call."""
|
||||||
|
|
||||||
def __init__(self, name: str, uri: str, token: str, no_push: bool = False, headers: Optional[dict[str, str]] = None, timeout: float = 10.0):
|
def __init__(
|
||||||
|
self,
|
||||||
|
name: str,
|
||||||
|
uri: str,
|
||||||
|
token: str,
|
||||||
|
no_push: bool = False,
|
||||||
|
headers: Optional[dict[str, str]] = None,
|
||||||
|
timeout: float = 10.0,
|
||||||
|
):
|
||||||
super().__init__(name, no_push)
|
super().__init__(name, no_push)
|
||||||
self.uri = uri.rstrip("/")
|
self.uri = uri.rstrip("/")
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
@@ -29,7 +37,7 @@ class API(Vault):
|
|||||||
url=f"{self.uri}/{service.lower()}/{kid}",
|
url=f"{self.uri}/{service.lower()}/{kid}",
|
||||||
headers={"Accept": "application/json"},
|
headers={"Accept": "application/json"},
|
||||||
timeout=self.timeout,
|
timeout=self.timeout,
|
||||||
allow_redirects=False
|
allow_redirects=False,
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
data = response.json()
|
data = response.json()
|
||||||
@@ -65,7 +73,7 @@ class API(Vault):
|
|||||||
params={"page": page, "total": 10},
|
params={"page": page, "total": 10},
|
||||||
headers={"Accept": "application/json"},
|
headers={"Accept": "application/json"},
|
||||||
timeout=self.timeout,
|
timeout=self.timeout,
|
||||||
allow_redirects=False
|
allow_redirects=False,
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
data = response.json()
|
data = response.json()
|
||||||
@@ -106,7 +114,7 @@ class API(Vault):
|
|||||||
json={"content_key": key},
|
json={"content_key": key},
|
||||||
headers={"Accept": "application/json"},
|
headers={"Accept": "application/json"},
|
||||||
timeout=self.timeout,
|
timeout=self.timeout,
|
||||||
allow_redirects=False
|
allow_redirects=False,
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
data = response.json()
|
data = response.json()
|
||||||
@@ -155,7 +163,7 @@ class API(Vault):
|
|||||||
json={"content_keys": batch_keys},
|
json={"content_keys": batch_keys},
|
||||||
headers={"Accept": "application/json"},
|
headers={"Accept": "application/json"},
|
||||||
timeout=self.timeout,
|
timeout=self.timeout,
|
||||||
allow_redirects=False
|
allow_redirects=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check for HTTP errors that suggest batch is too large
|
# Check for HTTP errors that suggest batch is too large
|
||||||
@@ -204,10 +212,7 @@ class API(Vault):
|
|||||||
|
|
||||||
def get_services(self) -> Iterator[str]:
|
def get_services(self) -> Iterator[str]:
|
||||||
response = self.session.post(
|
response = self.session.post(
|
||||||
url=self.uri,
|
url=self.uri, headers={"Accept": "application/json"}, timeout=self.timeout, allow_redirects=False
|
||||||
headers={"Accept": "application/json"},
|
|
||||||
timeout=self.timeout,
|
|
||||||
allow_redirects=False
|
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
data = response.json()
|
data = response.json()
|
||||||
@@ -250,4 +255,3 @@ class Exceptions:
|
|||||||
|
|
||||||
class ContentKeyInvalid(Exception):
|
class ContentKeyInvalid(Exception):
|
||||||
"""The Content Key is invalid."""
|
"""The Content Key is invalid."""
|
||||||
|
|
||||||
Reference in New Issue
Block a user