Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesWalczak committed Jan 24, 2024
1 parent 3a454a1 commit 5360b1b
Show file tree
Hide file tree
Showing 45 changed files with 278 additions and 110 deletions.
2 changes: 1 addition & 1 deletion api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG REGISTRY=rg.nl-ams.scw.cloud/geodds-production
ARG REGISTRY=rg.nl-ams.scw.cloud/geogeolake-production
ARG TAG=latest
FROM $REGISTRY/geolake-datastore:$TAG
WORKDIR /app
Expand Down
8 changes: 4 additions & 4 deletions api/app/auth/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
from dbmanager.dbmanager import DBManager

import exceptions as exc
from auth.models import DDSUser
from auth.models import GeoLakeUser
from auth import scopes


class DDSAuthenticationBackend(AuthenticationBackend):
class GeoLakeAuthenticationBackend(AuthenticationBackend):
"""Class managing authentication and authorization"""

async def authenticate(self, conn):
Expand All @@ -25,7 +25,7 @@ async def authenticate(self, conn):
def _manage_user_token_auth(self, user_token: str):
try:
user_id, api_key = self.get_authorization_scheme_param(user_token)
except exc.BaseDDSException as err:
except exc.BaseGeoLakeException as err:
raise err.wrap_around_http_exception()
user_dto = DBManager().get_user_details(user_id)
eligible_scopes = [scopes.AUTHENTICATED] + self._get_scopes_for_user(
Expand All @@ -35,7 +35,7 @@ def _manage_user_token_auth(self, user_token: str):
raise exc.AuthenticationFailed(
user_dto
).wrap_around_http_exception()
return AuthCredentials(eligible_scopes), DDSUser(username=user_id)
return AuthCredentials(eligible_scopes), GeoLakeUser(username=user_id)

def _get_scopes_for_user(self, user_dto) -> list[str]:
if user_dto is None:
Expand Down
4 changes: 2 additions & 2 deletions api/app/auth/manager.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Module with access/authentication functions"""
from typing import Optional

from utils.api_logging import get_dds_logger
from utils.api_logging import get_geolake_logger
import exceptions as exc

log = get_dds_logger(__name__)
log = get_geolake_logger(__name__)


def is_role_eligible_for_product(
Expand Down
6 changes: 3 additions & 3 deletions api/app/auth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from starlette.authentication import SimpleUser


class DDSUser(SimpleUser):
class GeoLakeUser(SimpleUser):
"""Immutable class containing information about the authenticated user"""

def __init__(self, username: str) -> None:
Expand All @@ -13,7 +13,7 @@ def id(self):
return self.username

def __eq__(self, other) -> bool:
if not isinstance(other, DDSUser):
if not isinstance(other, GeoLakeUser):
return False
if self.username == other.username:
return True
Expand All @@ -23,7 +23,7 @@ def __ne__(self, other):
return self != other

def __repr__(self):
return f"<DDSUser(username={self.username}>"
return f"<GeoLakeUser(username={self.username}>"

def __delattr__(self, name):
if getattr(self, name, None) is not None:
Expand Down
4 changes: 2 additions & 2 deletions api/app/callbacks/on_startup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Module with functions call during API server startup"""
from utils.api_logging import get_dds_logger
from utils.api_logging import get_geolake_logger

from datastore.datastore import Datastore

log = get_dds_logger(__name__)
log = get_geolake_logger(__name__)


def _load_cache() -> None:
Expand Down
4 changes: 2 additions & 2 deletions api/app/endpoint_handlers/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from datastore import exception as datastore_exception

from utils.metrics import log_execution_time
from utils.api_logging import get_dds_logger
from utils.api_logging import get_geolake_logger
from auth.manager import (
is_role_eligible_for_product,
)
Expand All @@ -23,7 +23,7 @@

from . import request

log = get_dds_logger(__name__)
log = get_geolake_logger(__name__)
data_store = Datastore()

MESSAGE_SEPARATOR = os.environ["MESSAGE_SEPARATOR"]
Expand Down
6 changes: 3 additions & 3 deletions api/app/endpoint_handlers/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from fastapi.responses import FileResponse
from dbmanager.dbmanager import DBManager, RequestStatus

from utils.api_logging import get_dds_logger
from utils.api_logging import get_geolake_logger
from utils.metrics import log_execution_time
import exceptions as exc

log = get_dds_logger(__name__)
log = get_geolake_logger(__name__)


@log_execution_time(log)
Expand All @@ -33,7 +33,7 @@ def download_request_result(request_id: int):
Raises
-------
RequestNotYetAccomplished
If dds request was not yet finished
If geolake request was not yet finished
FileNotFoundError
If file was not found
"""
Expand Down
4 changes: 2 additions & 2 deletions api/app/endpoint_handlers/request.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Modules with functions realizing logic for requests-related endpoints"""
from dbmanager.dbmanager import DBManager

from utils.api_logging import get_dds_logger
from utils.api_logging import get_geolake_logger
from utils.metrics import log_execution_time
import exceptions as exc

log = get_dds_logger(__name__)
log = get_geolake_logger(__name__)


@log_execution_time(log)
Expand Down
36 changes: 18 additions & 18 deletions api/app/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Module with DDS exceptions definitions"""
"""Module with GeoLake exceptions definitions"""
from typing import Optional

from fastapi import HTTPException


class BaseDDSException(BaseException):
"""Base class for DDS.api exceptions"""
class BaseGeoLakeException(BaseException):
"""Base class for GeoLake.api exceptions"""

msg: str = "Bad request"
code: int = 400
Expand All @@ -18,13 +18,13 @@ def wrap_around_http_exception(self) -> HTTPException:
)


class EmptyUserTokenError(BaseDDSException):
class EmptyUserTokenError(BaseGeoLakeException):
"""Raised if `User-Token` is empty"""

msg: str = "User-Token cannot be empty!"


class ImproperUserTokenError(BaseDDSException):
class ImproperUserTokenError(BaseGeoLakeException):
"""Raised if `User-Token` format is wrong"""

msg: str = (
Expand All @@ -33,7 +33,7 @@ class ImproperUserTokenError(BaseDDSException):
)


class NoEligibleProductInDatasetError(BaseDDSException):
class NoEligibleProductInDatasetError(BaseGeoLakeException):
"""No eligible products in the dataset Error"""

msg: str = (
Expand All @@ -48,7 +48,7 @@ def __init__(self, dataset_id: str, user_roles_names: list[str]) -> None:
super().__init__(self.msg)


class MissingKeyInCatalogEntryError(BaseDDSException):
class MissingKeyInCatalogEntryError(BaseGeoLakeException):
"""Missing key in the catalog entry"""

msg: str = (
Expand All @@ -60,7 +60,7 @@ def __init__(self, key, dataset):
super().__init__(self.msg)


class MaximumAllowedSizeExceededError(BaseDDSException):
class MaximumAllowedSizeExceededError(BaseGeoLakeException):
"""Estimated size is too big"""

msg: str = (
Expand All @@ -81,8 +81,8 @@ def __init__(
super().__init__(self.msg)


class RequestNotYetAccomplished(BaseDDSException):
"""Raised if dds request was not finished yet"""
class RequestNotYetAccomplished(BaseGeoLakeException):
"""Raised if geolake request was not finished yet"""

msg: str = (
"Request with id: {request_id} does not exist or it is not"
Expand All @@ -94,7 +94,7 @@ def __init__(self, request_id):
super().__init__(self.msg)


class RequestNotFound(BaseDDSException):
class RequestNotFound(BaseGeoLakeException):
"""If the given request could not be found"""

msg: str = "Request with ID '{request_id}' was not found"
Expand All @@ -104,7 +104,7 @@ def __init__(self, request_id: int) -> None:
super().__init__(self.msg)


class RequestStatusNotDone(BaseDDSException):
class RequestStatusNotDone(BaseGeoLakeException):
"""Raised when the submitted request failed"""

msg: str = (
Expand All @@ -119,7 +119,7 @@ def __init__(self, request_id, request_status) -> None:
super().__init__(self.msg)


class AuthorizationFailed(BaseDDSException):
class AuthorizationFailed(BaseGeoLakeException):
"""Raised when the user is not authorized for the given resource"""

msg: str = "{user} is not authorized for the resource!"
Expand All @@ -133,7 +133,7 @@ def __init__(self, user_id: Optional[str] = None):
super().__init__(self.msg)


class AuthenticationFailed(BaseDDSException):
class AuthenticationFailed(BaseGeoLakeException):
"""Raised when the key of the provided user differs from the one s
tored in the DB"""

Expand All @@ -145,7 +145,7 @@ def __init__(self, user_id: str):
super().__init__(self.msg)


class MissingDatasetError(BaseDDSException):
class MissingDatasetError(BaseGeoLakeException):
"""Raied if the queried dataset is not present in the catalog"""

msg: str = "Dataset '{dataset_id}' does not exist in the catalog!"
Expand All @@ -155,7 +155,7 @@ def __init__(self, dataset_id: str):
super().__init__(self.msg)


class MissingProductError(BaseDDSException):
class MissingProductError(BaseGeoLakeException):
"""Raised if the requested product is not defined for the dataset"""

msg: str = (
Expand All @@ -169,7 +169,7 @@ def __init__(self, dataset_id: str, product_id: str):
super().__init__(self.msg)


class EmptyDatasetError(BaseDDSException):
class EmptyDatasetError(BaseGeoLakeException):
"""The size of the requested dataset is zero"""

msg: str = "The resulting dataset '{dataset_id}.{product_id}' is empty"
Expand All @@ -181,7 +181,7 @@ def __init__(self, dataset_id, product_id):
)
super().__init__(self.msg)

class ProductRetrievingError(BaseDDSException):
class ProductRetrievingError(BaseGeoLakeException):
"""Retrieving of the product failed."""

msg: str = "Retrieving of the product '{dataset_id}.{product_id}' failed with the status {status}"
Expand Down
Loading

0 comments on commit 5360b1b

Please sign in to comment.