-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial structure of everything so far. I have been working on fleshi…
…ng out the Auth interface as suggested by Peter, and made some progress.
- Loading branch information
1 parent
5d3fbed
commit c4f12d0
Showing
13 changed files
with
1,499 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
registry client, provena client. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from ..utils.Auth import Auth | ||
from ..utils.Config import Config | ||
from ..utils.httpClient import HttpClient | ||
|
||
class RegistryClient: | ||
|
||
URL_MAP = { | ||
(REGISTRY_ACTION, SUBTYPE) : "url" | ||
} | ||
|
||
auth: Auth | ||
config: Config | ||
|
||
def __init__(self, auth: Auth, config: Config): | ||
self.auth = auth, | ||
self.config = config | ||
|
||
async def fetch_item(request_model: RequestModel, entity_subtype: ItemSubType) -> ItemPerson: | ||
|
||
# To complete this method. | ||
get_auth = ().. | ||
|
||
try: | ||
url =self.URL_MAP[REGISTRY_API.FETCH_ITEM, entity_subtype] | ||
|
||
|
||
try: | ||
|
||
response = await HttpClient.make_get_request(url = url, body=request_model.dict(), params = validated_id.id, headers = get_auth_headers) # Retrieve the response object. | ||
|
||
# Handling the HTTP/Application level errors here | ||
if response.status_code != 200: | ||
if response.status_code == 401: | ||
# TODO Define custom exceptions for common scenarios e.g. Auth | ||
raise Exception(f"Authorisation exception...") | ||
if response.status_code >= 500: | ||
raise UnexpectedException(...) | ||
|
||
except Exception as e: | ||
raise ValueError("Failed to fetch item.") | ||
|
||
# parse as json | ||
json_response = response.json() | ||
|
||
try: | ||
parsed_model = ItemModel.parse_json(json_response) | ||
except: | ||
# raise exception here for validation | ||
|
||
# check for status if applicable | ||
if not parsed_model.status: | ||
raise Exception(#status details | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from ..utils.Auth import Auth | ||
from ..utils.Config import Config | ||
from ..clients.RegistryClient import RegistryClient | ||
|
||
class ProvenaClient(): | ||
auth: Auth, | ||
config: Config | ||
|
||
_registry_client: RegistryClient | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
provenaclient, registry. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,5 @@ | ||
from dataclasses import dataclass | ||
from .utils.Auth import Auth | ||
from .utils.Config import Config | ||
|
||
@dataclass | ||
class Settings: | ||
domain: str | ||
|
||
class Auth: | ||
def __init__(self, settings: Settings): | ||
self.settings = settings | ||
|
||
class Client: | ||
def __init__(self, auth: Auth, settings: Settings): | ||
self.auth = auth | ||
self.settings = settings | ||
|
||
config = Config(registry_api_endpoint=) |
Oops, something went wrong.