Skip to content

Commit

Permalink
Initial structure of everything so far. I have been working on fleshi…
Browse files Browse the repository at this point in the history
…ng out the Auth interface as suggested by Peter, and made some progress.
  • Loading branch information
parth-kulkarni1 committed Apr 26, 2024
1 parent 5d3fbed commit c4f12d0
Show file tree
Hide file tree
Showing 13 changed files with 1,499 additions and 14 deletions.
188 changes: 187 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ readme = "README.md"

[tool.poetry.dependencies]
python = "^3.9"
httpx = "^0.27.0"
pydantic-settings = "^2.2.1"
python-jose = "^3.3.0"

[tool.poetry.dev-dependencies]
mypy = "^1.9.0"
Expand Down
1 change: 1 addition & 0 deletions src/provenaclient/clients/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry client, provena client.
54 changes: 54 additions & 0 deletions src/provenaclient/clients/RegistryClient.py
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
)

10 changes: 10 additions & 0 deletions src/provenaclient/modules/ProvenaClient.py
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

1 change: 1 addition & 0 deletions src/provenaclient/modules/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
provenaclient, registry.
16 changes: 3 additions & 13 deletions src/provenaclient/provena_client.py
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=)
Loading

0 comments on commit c4f12d0

Please sign in to comment.