Skip to content

Commit

Permalink
fix fetching of capabilities (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
singhpranjali authored Nov 8, 2022
1 parent 4043b03 commit 3df280d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions marketplace/app/v0_0_1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""


from typing import List
from urllib.parse import urljoin

from ..utils import camel_to_snake, check_capability_availability
Expand All @@ -25,20 +26,20 @@ def __init__(self, client_id, capabilities: list = None, **kwargs):
super().__init__(**kwargs)
self.client_id = client_id
# Must be run before the marketplace_host_url is updated to include the proxy.
self.capabilities = capabilities or self.set_capabilities()
self.capabilities = capabilities or self.get_capabilities()
self.marketplace_host_url = urljoin(
self.marketplace_host_url, f"api/applications/proxy/{self.client_id}/"
)

def set_capabilities(self):
def get_capabilities(self) -> List[str]:
"""Query the platform to get the capabilities supported by a certain
app."""
app_service_path = f"api/applications/{self.client_id}"
response = self.get(path=app_service_path).json()
capability_info = response["capabilities"]
self.capabilities = []
for capability in capability_info:
self.capabilities.append(camel_to_snake(capability["name"]))
return [
camel_to_snake(capability["name"])
for capability in response["capabilities"]
]

@check_capability_availability
def heartbeat(self) -> str:
Expand Down

0 comments on commit 3df280d

Please sign in to comment.