From 8e7f3301d15e9498b0807b46c727226787176831 Mon Sep 17 00:00:00 2001 From: Ethan Paul Date: Sun, 23 Feb 2020 01:44:08 -0500 Subject: [PATCH] Add resources submodules and basic infrastructure --- keyosk/resources/__init__.py | 28 ++++++++++++++++++++ keyosk/resources/account.py | 47 ++++++++++++++++++++++++++++++++++ keyosk/resources/auth.py | 13 ++++++++++ keyosk/resources/blacklist.py | 16 ++++++++++++ keyosk/resources/domain.py | 44 +++++++++++++++++++++++++++++++ keyosk/resources/openapi.py | 13 ++++++++++ keyosk/resources/public_key.py | 13 ++++++++++ 7 files changed, 174 insertions(+) create mode 100644 keyosk/resources/__init__.py create mode 100644 keyosk/resources/account.py create mode 100644 keyosk/resources/auth.py create mode 100644 keyosk/resources/blacklist.py create mode 100644 keyosk/resources/domain.py create mode 100644 keyosk/resources/openapi.py create mode 100644 keyosk/resources/public_key.py diff --git a/keyosk/resources/__init__.py b/keyosk/resources/__init__.py new file mode 100644 index 0000000..c5ecdbb --- /dev/null +++ b/keyosk/resources/__init__.py @@ -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, +] diff --git a/keyosk/resources/account.py b/keyosk/resources/account.py new file mode 100644 index 0000000..70f108a --- /dev/null +++ b/keyosk/resources/account.py @@ -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//" + + 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//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)) diff --git a/keyosk/resources/auth.py b/keyosk/resources/auth.py new file mode 100644 index 0000000..e6caae9 --- /dev/null +++ b/keyosk/resources/auth.py @@ -0,0 +1,13 @@ +from keyosk.resources._shared import KeyoskResource +from keyosk.resources._shared import ResponseTuple + + +class AuthenticationResource(KeyoskResource): + + ROUTES = "/auth/" + + def get(self, domain_ref: str) -> ResponseTuple: + raise NotADirectoryError + + def head(self, domain_ref: str) -> ResponseTuple: + raise NotImplementedError diff --git a/keyosk/resources/blacklist.py b/keyosk/resources/blacklist.py new file mode 100644 index 0000000..8d53c09 --- /dev/null +++ b/keyosk/resources/blacklist.py @@ -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()) diff --git a/keyosk/resources/domain.py b/keyosk/resources/domain.py new file mode 100644 index 0000000..9740fed --- /dev/null +++ b/keyosk/resources/domain.py @@ -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//" + + 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//audit" + + def get(self, domain_ref: str) -> ResponseTuple: + raise NotADirectoryError + + def head(self, domain_ref: str) -> ResponseTuple: + return self._head(self.get(domain_ref)) diff --git a/keyosk/resources/openapi.py b/keyosk/resources/openapi.py new file mode 100644 index 0000000..904a8b3 --- /dev/null +++ b/keyosk/resources/openapi.py @@ -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()) diff --git a/keyosk/resources/public_key.py b/keyosk/resources/public_key.py new file mode 100644 index 0000000..13b3ef0 --- /dev/null +++ b/keyosk/resources/public_key.py @@ -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())