1
0
mirror of https://github.com/enpaul/keyosk.git synced 2024-11-05 06:07:06 +00:00

Add resources submodules and basic infrastructure

This commit is contained in:
Ethan Paul 2020-02-23 01:44:08 -05:00
parent 90ea657ee9
commit 8e7f3301d1
7 changed files with 174 additions and 0 deletions

View File

@ -0,0 +1,28 @@
from typing import List
from typing import Type
from keyosk.resources._shared import KeyoskResource
from keyosk.resources.account import AccountMultiResource
from keyosk.resources.account import AccountPermissionResource
from keyosk.resources.account import AccountSingleResource
from keyosk.resources.auth import AuthenticationResource
from keyosk.resources.blacklist import BlacklistResource
from keyosk.resources.domain import DomainAuditResource
from keyosk.resources.domain import DomainMultiResource
from keyosk.resources.domain import DomainSingleResource
from keyosk.resources.openapi import OpenAPIResource
from keyosk.resources.public_key import PublicKeyResource
RESOURCES: List[Type[KeyoskResource]] = [
AuthenticationResource,
OpenAPIResource,
PublicKeyResource,
BlacklistResource,
DomainMultiResource,
DomainSingleResource,
DomainAuditResource,
AccountMultiResource,
AccountSingleResource,
AccountPermissionResource,
]

View File

@ -0,0 +1,47 @@
from keyosk.resources._shared import KeyoskResource
from keyosk.resources._shared import ResponseTuple
class AccountMultiResource(KeyoskResource):
ROUTES = ("/account/",)
def get(self) -> ResponseTuple:
raise NotImplementedError
def post(self) -> ResponseTuple:
raise NotImplementedError
def head(self) -> ResponseTuple:
return self._head(self.get())
class AccountSingleResource(KeyoskResource):
ROUTES = "/account/<string:account_ref>/"
def get(self, account_ref: str) -> ResponseTuple:
raise NotADirectoryError
def patch(self, account_ref: str) -> ResponseTuple:
raise NotADirectoryError
def delete(self, account_ref: str) -> ResponseTuple:
raise NotADirectoryError
def head(self, account_ref: str) -> ResponseTuple:
return self._head(self.get(account_ref))
class AccountPermissionResource(KeyoskResource):
ROUTES = "/account/<string:account_ref>/permission"
def get(self, account_ref: str) -> ResponseTuple:
raise NotADirectoryError
def patch(self, account_ref: str) -> ResponseTuple:
raise NotADirectoryError
def head(self, account_ref: str) -> ResponseTuple:
return self._head(self.get(account_ref))

13
keyosk/resources/auth.py Normal file
View File

@ -0,0 +1,13 @@
from keyosk.resources._shared import KeyoskResource
from keyosk.resources._shared import ResponseTuple
class AuthenticationResource(KeyoskResource):
ROUTES = "/auth/<string:domain_ref>"
def get(self, domain_ref: str) -> ResponseTuple:
raise NotADirectoryError
def head(self, domain_ref: str) -> ResponseTuple:
raise NotImplementedError

View File

@ -0,0 +1,16 @@
from keyosk.resources._shared import KeyoskResource
from keyosk.resources._shared import ResponseTuple
class BlacklistResource(KeyoskResource):
ROUTES = ("/blacklist/",)
def get(self) -> ResponseTuple:
raise NotImplementedError
def post(self) -> ResponseTuple:
raise NotImplementedError
def head(self) -> ResponseTuple:
return self._head(self.get())

View File

@ -0,0 +1,44 @@
from keyosk.resources._shared import KeyoskResource
from keyosk.resources._shared import ResponseTuple
class DomainMultiResource(KeyoskResource):
ROUTES = ("/domain/",)
def get(self) -> ResponseTuple:
raise NotImplementedError
def post(self) -> ResponseTuple:
raise NotImplementedError
def head(self) -> ResponseTuple:
return self._head(self.get())
class DomainSingleResource(KeyoskResource):
ROUTES = "/domain/<string:domain_ref>/"
def get(self, domain_ref: str) -> ResponseTuple:
raise NotADirectoryError
def patch(self, domain_ref: str) -> ResponseTuple:
raise NotADirectoryError
def delete(self, domain_ref: str) -> ResponseTuple:
raise NotADirectoryError
def head(self, domain_ref: str) -> ResponseTuple:
return self._head(self.get(domain_ref))
class DomainAuditResource(KeyoskResource):
ROUTES = "/domain/<string:domain_ref>/audit"
def get(self, domain_ref: str) -> ResponseTuple:
raise NotADirectoryError
def head(self, domain_ref: str) -> ResponseTuple:
return self._head(self.get(domain_ref))

View File

@ -0,0 +1,13 @@
from keyosk.resources._shared import KeyoskResource
from keyosk.resources._shared import ResponseTuple
class OpenAPIResource(KeyoskResource):
ROUTES = ("/openapi.json",)
def get(self) -> ResponseTuple:
raise NotImplementedError
def head(self) -> ResponseTuple:
return self._head(self.get())

View File

@ -0,0 +1,13 @@
from keyosk.resources._shared import KeyoskResource
from keyosk.resources._shared import ResponseTuple
class PublicKeyResource(KeyoskResource):
ROUTES = ("/public-key",)
def get(self) -> ResponseTuple:
raise NotImplementedError
def head(self) -> ResponseTuple:
return self._head(self.get())