From feae618ed5a8a2e8d3e4049ce972a9730514ff1f Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Thu, 17 Sep 2020 22:22:24 -0400 Subject: [PATCH] Add initial resource skeleton to match openapi spec --- imagemonk/resources/__init__.py | 7 +++++++ imagemonk/resources/image.py | 26 ++++++++++++++++++++++++++ imagemonk/resources/openapi.py | 15 +++++++++++++++ imagemonk/resources/thumbnail.py | 17 +++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 imagemonk/resources/__init__.py create mode 100644 imagemonk/resources/image.py create mode 100644 imagemonk/resources/openapi.py create mode 100644 imagemonk/resources/thumbnail.py diff --git a/imagemonk/resources/__init__.py b/imagemonk/resources/__init__.py new file mode 100644 index 0000000..5a66702 --- /dev/null +++ b/imagemonk/resources/__init__.py @@ -0,0 +1,7 @@ +from imagemonk.resources.image import Image +from imagemonk.resources.image import ImageUpload +from imagemonk.resources.thumbnail import ThumbnailResize +from imagemonk.resources.thumbnail import ThumbnailScale + + +RESOURCES = (ImageUpload, Image, ThumbnailScale, ThumbnailResize) diff --git a/imagemonk/resources/image.py b/imagemonk/resources/image.py new file mode 100644 index 0000000..a27844f --- /dev/null +++ b/imagemonk/resources/image.py @@ -0,0 +1,26 @@ +import flask_restful + + +class ImageUpload(flask_restful.Resource): + + route = "/image/" + + def put(self): + raise NotImplementedError + + def options(self): + raise NotImplementedError + + +class Image(flask_restful.Resource): + + route = "/image/.jpg" + + def get(self, image_id: str): + raise NotImplementedError + + def delete(self, image_id: str): + raise NotImplementedError + + def options(self, image_id: str): + raise NotImplementedError diff --git a/imagemonk/resources/openapi.py b/imagemonk/resources/openapi.py new file mode 100644 index 0000000..b5bd942 --- /dev/null +++ b/imagemonk/resources/openapi.py @@ -0,0 +1,15 @@ +from pathlib import Path + +import flask_restful +from ruamel.yaml import YAML + +yaml = YAML(typ="safe") + + +class OpenAPI(flask_restful.Resource): + def get(self): + + with (Path(__file__).parent, "openapi.yaml").open() as infile: + data = yaml.load(infile) + + return data, 200 diff --git a/imagemonk/resources/thumbnail.py b/imagemonk/resources/thumbnail.py new file mode 100644 index 0000000..2b5eca9 --- /dev/null +++ b/imagemonk/resources/thumbnail.py @@ -0,0 +1,17 @@ +import flask_restful + + +class ThumbnailScale(flask_restful.Resource): + + route = "/thumb//scale/.jpg" + + def get(self, image_id: str, scale_width: int): + raise NotImplementedError + + +class ThumbnailResize(flask_restful.Resource): + + route = "/thumb//size/x.jpg" + + def get(self, image_id: str, width: int, height: int): + raise NotImplementedError