Skip to content

Commit

Permalink
Remove v0.0.1 support (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo-de-andres authored Jun 13, 2023
1 parent 8cb1040 commit 31ba928
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 466 deletions.
12 changes: 0 additions & 12 deletions examples/mp_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from marketplace.app import get_app
from marketplace.app.v0 import MarketPlaceApp
from marketplace.app.v0_0_1 import MarketPlaceApp as MarketPlaceApp_v_0_0_1
from marketplace.client import MarketPlaceClient

# General MarketPlaceClient for simple requests like user info
Expand All @@ -30,14 +29,3 @@ def heartbeat(self) -> HTMLResponse:

my_mp_app = MyMarketPlaceApp(app_id="<application_client_id>")
print(my_mp_app.heartbeat())


# To extend the MarketPlaceApp with custom implementations for deprecated api version 0.0.1
class MyMarketPlaceApp_v_0_0_1(MarketPlaceApp_v_0_0_1):
def heartbeat(self) -> str:
res = super().heartbeat()
return f"heartbeat response: {res}"


my_mp_app_v_0_0_1 = MyMarketPlaceApp_v_0_0_1(client_id="<application_client_id>")
print(my_mp_app_v_0_0_1.heartbeat())
27 changes: 2 additions & 25 deletions marketplace/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,13 @@
.. currentmodule:: marketplace.app
.. moduleauthor:: Pablo de Andres, Pranjali Singh (Fraunhofer IWM)
"""
import warnings
from typing import Optional

from packaging.version import parse

from ..client import MarketPlaceClient
from .utils import camel_to_snake
from .v0 import MarketPlaceApp as _MarketPlaceApp_v0
from .v0_0_1 import MarketPlaceApp as _MarketPlaceApp_v0_0_1


class MarketPlaceApp(_MarketPlaceApp_v0_0_1):
def __init__(self, *args, **kwargs):
warnings.warn(
"The MarketPlaceApp class is deprecated as of v0.2.0 and will be "
"removed in v1. Please use the get_app() function instead."
)
super().__init__(*args, **kwargs)


def get_app(app_id, client: Optional[MarketPlaceClient] = None, **kwargs):
Expand All @@ -36,25 +25,13 @@ def get_app(app_id, client: Optional[MarketPlaceClient] = None, **kwargs):
# Getting api version and list of capabilities for the application
app_service_path = f"api/applications/{app_id}"
app_info: dict = client.get(path=app_service_path).json()
app_api_version = parse(app_info.get("api_version", "0.0.1"))
app_api_version = parse(app_info.get("api_version", "1.0.0"))

capabilities = []
for capability in app_info["capabilities"]:
capabilities.append(camel_to_snake(capability["name"]))

if app_api_version == parse("0.0.1"):
if client is not None:
raise RuntimeError(
"Cannot use existing client for apps with API version 0.0.1."
)
return _MarketPlaceApp_v0_0_1(
app_id,
marketplace_host_url=kwargs.get("marketplace_host_url"),
access_token=kwargs.get("access_token"),
capabilities=capabilities,
**kwargs,
)
elif parse("0.0.1") < app_api_version <= parse("0.3.0"):
if app_api_version < parse("1.0.0"):
return _MarketPlaceApp_v0(app_id, app_info, client, **kwargs)
else:
raise RuntimeError(f"App API version ({app_api_version}) not supported.")
Expand Down
50 changes: 0 additions & 50 deletions marketplace/app/v0_0_1/__init__.py

This file was deleted.

125 changes: 0 additions & 125 deletions marketplace/app/v0_0_1/data_sink_app.py

This file was deleted.

Loading

0 comments on commit 31ba928

Please sign in to comment.