diff --git a/Dockerfile b/Dockerfile index 543a72a..9c392de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,12 +18,11 @@ FROM python:3.11-alpine COPY --from=builder /app/.venv /app/.venv ENV PATH="/app/.venv/bin:$PATH" -COPY ./logging.json . -COPY ./gateway/ ./gateway/ +COPY hub_adapter/ ./hub_adapter/ # API server port EXPOSE 5000 -ENTRYPOINT ["python", "-m", "gateway.cli", "serve"] +ENTRYPOINT ["python", "-m", "hub_adapter.cli", "serve"] -HEALTHCHECK CMD curl --fail http://localhost:5000/health || exit 1 +HEALTHCHECK CMD curl --fail http://localhost:5000/healthz || exit 1 diff --git a/gateway/__init__.py b/hub_adapter/__init__.py similarity index 100% rename from gateway/__init__.py rename to hub_adapter/__init__.py diff --git a/gateway/auth.py b/hub_adapter/auth.py similarity index 84% rename from gateway/auth.py rename to hub_adapter/auth.py index a1fc11b..571cb3b 100644 --- a/gateway/auth.py +++ b/hub_adapter/auth.py @@ -9,19 +9,19 @@ from starlette.datastructures import MutableHeaders from starlette.requests import Request -from gateway.conf import gateway_settings -from gateway.models.conf import AuthConfiguration, Token +from hub_adapter.conf import hub_adapter_settings +from hub_adapter.models.conf import AuthConfiguration, Token logger = logging.getLogger(__name__) -IDP_ISSUER_URL = gateway_settings.IDP_URL.rstrip("/") + "/" + "/".join(["realms", gateway_settings.IDP_REALM]) +IDP_ISSUER_URL = hub_adapter_settings.IDP_URL.rstrip("/") + "/" + "/".join(["realms", hub_adapter_settings.IDP_REALM]) # IDP i.e. Keycloak realm_idp_settings = AuthConfiguration( - server_url=gateway_settings.IDP_URL, - realm=gateway_settings.IDP_REALM, - client_id=gateway_settings.API_CLIENT_ID, - client_secret=gateway_settings.API_CLIENT_SECRET, + server_url=hub_adapter_settings.IDP_URL, + realm=hub_adapter_settings.IDP_REALM, + client_id=hub_adapter_settings.API_CLIENT_ID, + client_secret=hub_adapter_settings.API_CLIENT_SECRET, authorization_url=IDP_ISSUER_URL + "/protocol/openid-connect/auth", token_url=IDP_ISSUER_URL + "/protocol/openid-connect/token", issuer_url=IDP_ISSUER_URL, @@ -52,7 +52,7 @@ async def get_idp_public_key() -> str: async def get_hub_public_key() -> dict: """Get the central hub service public key.""" - hub_jwks_ep = gateway_settings.HUB_AUTH_SERVICE_URL.rstrip("/") + "/jwks" + hub_jwks_ep = hub_adapter_settings.HUB_AUTH_SERVICE_URL.rstrip("/") + "/jwks" return httpx.get(hub_jwks_ep).json() @@ -100,9 +100,9 @@ async def verify_idp_token(token: str = Security(idp_oauth2_scheme)) -> dict: async def get_hub_token() -> dict: """Automated method for getting a token from the central Hub service.""" - hub_user, hub_pwd = gateway_settings.HUB_USERNAME, gateway_settings.HUB_PASSWORD + hub_user, hub_pwd = hub_adapter_settings.HUB_USERNAME, hub_adapter_settings.HUB_PASSWORD payload = {"username": hub_user, "password": hub_pwd} - token_route = gateway_settings.HUB_AUTH_SERVICE_URL.rstrip("/") + "/token" + token_route = hub_adapter_settings.HUB_AUTH_SERVICE_URL.rstrip("/") + "/token" resp = httpx.post(token_route, data=payload) if not resp.status_code == httpx.codes.OK: diff --git a/gateway/cli.py b/hub_adapter/cli.py similarity index 88% rename from gateway/cli.py rename to hub_adapter/cli.py index 2b31e13..a87eb3d 100644 --- a/gateway/cli.py +++ b/hub_adapter/cli.py @@ -21,7 +21,7 @@ def main(): @click.option("-r", "--reload", is_flag=True, default=False, help="Enable reload") def serve(host, port, reload): """Start the API RESTful server.""" - uvicorn.run("gateway.server:app", host=host, port=int(port), reload=reload) + uvicorn.run("hub_adapter.server:app", host=host, port=int(port), reload=reload) if __name__ == "__main__": diff --git a/gateway/conf.py b/hub_adapter/conf.py similarity index 53% rename from gateway/conf.py rename to hub_adapter/conf.py index b427e90..046ed4d 100644 --- a/gateway/conf.py +++ b/hub_adapter/conf.py @@ -1,5 +1,9 @@ """Adapter API Settings.""" +import logging +import logging.handlers as handlers import os +import sys +from pathlib import Path from pydantic import BaseModel @@ -11,9 +15,6 @@ class Settings(BaseModel): ACCESS_TOKEN_DEFAULT_EXPIRE_MINUTES: int = 360 GATEWAY_TIMEOUT: int = 59 - # K8s - K8S_API_KEY: str = os.getenv("K8S_API_KEY") - # IDP Settings IDP_URL: str = os.getenv("IDP_URL", "http://localhost:8080") IDP_REALM: str = os.getenv("IDP_REALM", "flame") @@ -34,4 +35,31 @@ class Settings(BaseModel): HUB_PASSWORD: str = os.getenv("HUB_PASSWORD") -gateway_settings = Settings() +hub_adapter_settings = Settings() + +# Logging +root_dir = Path(__file__).parent.resolve() +log_dir = root_dir.joinpath("logs") +log_dir.mkdir(parents=True, exist_ok=True) + +main_logger = logging.getLogger("hub_adapter") + +# Log Handler +logHandler = handlers.RotatingFileHandler( + filename=log_dir.joinpath("node_hub_api_adapter.log"), + mode="a", + maxBytes=4098 * 10, # 4MB file max + backupCount=5, +) +logh_format = logging.Formatter("%(levelname)s - %(module)s:L%(lineno)d - %(asctime)s - %(message)s") +logHandler.setFormatter(logh_format) +logHandler.setLevel(logging.DEBUG) + +# Console Handler +streamHandler = logging.StreamHandler(stream=sys.stderr) +stream_format = logging.Formatter("%(asctime)s - %(levelname)s: %(message)s") +streamHandler.setFormatter(stream_format) +streamHandler.setLevel(logging.WARNING) + +main_logger.addHandler(logHandler) +main_logger.addHandler(streamHandler) diff --git a/gateway/constants.py b/hub_adapter/constants.py similarity index 100% rename from gateway/constants.py rename to hub_adapter/constants.py diff --git a/gateway/core.py b/hub_adapter/core.py similarity index 97% rename from gateway/core.py rename to hub_adapter/core.py index d990ad2..e22e019 100644 --- a/gateway/core.py +++ b/hub_adapter/core.py @@ -11,9 +11,9 @@ from httpx import ConnectError, DecodingError from starlette.responses import Response, FileResponse -from gateway import post_processing -from gateway.constants import CONTENT_TYPE -from gateway.utils import unzip_form_params, unzip_body_object, create_request_data, unzip_query_params, \ +from hub_adapter import post_processing +from hub_adapter.constants import CONTENT_TYPE +from hub_adapter.utils import unzip_form_params, unzip_body_object, create_request_data, unzip_query_params, \ unzip_file_params logger = logging.getLogger(__name__) diff --git a/gateway/models/__init__.py b/hub_adapter/models/__init__.py similarity index 100% rename from gateway/models/__init__.py rename to hub_adapter/models/__init__.py diff --git a/gateway/models/conf.py b/hub_adapter/models/conf.py similarity index 100% rename from gateway/models/conf.py rename to hub_adapter/models/conf.py diff --git a/gateway/models/health.py b/hub_adapter/models/health.py similarity index 100% rename from gateway/models/health.py rename to hub_adapter/models/health.py diff --git a/gateway/models/hub.py b/hub_adapter/models/hub.py similarity index 100% rename from gateway/models/hub.py rename to hub_adapter/models/hub.py diff --git a/gateway/models/kong.py b/hub_adapter/models/kong.py similarity index 100% rename from gateway/models/kong.py rename to hub_adapter/models/kong.py diff --git a/gateway/models/podorc.py b/hub_adapter/models/podorc.py similarity index 100% rename from gateway/models/podorc.py rename to hub_adapter/models/podorc.py diff --git a/gateway/models/results.py b/hub_adapter/models/results.py similarity index 100% rename from gateway/models/results.py rename to hub_adapter/models/results.py diff --git a/gateway/post_processing.py b/hub_adapter/post_processing.py similarity index 100% rename from gateway/post_processing.py rename to hub_adapter/post_processing.py diff --git a/gateway/routers/__init__.py b/hub_adapter/routers/__init__.py similarity index 100% rename from gateway/routers/__init__.py rename to hub_adapter/routers/__init__.py diff --git a/gateway/routers/health.py b/hub_adapter/routers/health.py similarity index 77% rename from gateway/routers/health.py rename to hub_adapter/routers/health.py index 2434d2d..a8b7f27 100644 --- a/gateway/routers/health.py +++ b/hub_adapter/routers/health.py @@ -4,8 +4,8 @@ from fastapi import APIRouter from starlette import status -from gateway.conf import gateway_settings -from gateway.models.health import HealthCheck, DownstreamHealthCheck +from hub_adapter.conf import hub_adapter_settings +from hub_adapter.models.health import HealthCheck, DownstreamHealthCheck health_router = APIRouter( tags=["Health"], @@ -44,9 +44,9 @@ def get_health() -> HealthCheck: def get_health_downstream_services() -> DownstreamHealthCheck: """Return the health of the downstream microservices.""" health_eps = { - "po": gateway_settings.PODORC_SERVICE_URL.rstrip("/") + "/healthz", - "results": gateway_settings.RESULTS_SERVICE_URL.rstrip("/") + "/healthz", - "hub": gateway_settings.HUB_SERVICE_URL, - "kong": gateway_settings.KONG_ADMIN_SERVICE_URL, + "po": hub_adapter_settings.PODORC_SERVICE_URL.rstrip("/") + "/healthz", + "results": hub_adapter_settings.RESULTS_SERVICE_URL.rstrip("/") + "/healthz", + "hub": hub_adapter_settings.HUB_SERVICE_URL, + "kong": hub_adapter_settings.KONG_ADMIN_SERVICE_URL, } return health_eps diff --git a/gateway/routers/hub.py b/hub_adapter/routers/hub.py similarity index 91% rename from gateway/routers/hub.py rename to hub_adapter/routers/hub.py index bfc4c93..c7052be 100644 --- a/gateway/routers/hub.py +++ b/hub_adapter/routers/hub.py @@ -7,12 +7,13 @@ from starlette.requests import Request from starlette.responses import Response -from gateway.auth import add_hub_jwt, verify_idp_token, idp_oauth2_scheme_pass, httpbearer -from gateway.conf import gateway_settings -from gateway.core import route -from gateway.models.hub import Project, AllProjects, ApprovalStatus, AnalysisOrProjectNode, ListAnalysisOrProjectNodes, \ +from hub_adapter.auth import add_hub_jwt, verify_idp_token, idp_oauth2_scheme_pass, httpbearer +from hub_adapter.conf import hub_adapter_settings +from hub_adapter.core import route +from hub_adapter.models.hub import Project, AllProjects, ApprovalStatus, AnalysisOrProjectNode, \ + ListAnalysisOrProjectNodes, \ AnalysisNode -from gateway.models.podorc import ImageDataResponse, ContainerResponse +from hub_adapter.models.podorc import ImageDataResponse, ContainerResponse hub_router = APIRouter( dependencies=[Security(verify_idp_token), Depends(add_hub_jwt), Security(idp_oauth2_scheme_pass), @@ -69,7 +70,7 @@ async def get_vault_status(): request_method=hub_router.get, path="/projects", status_code=status.HTTP_200_OK, - service_url=gateway_settings.HUB_SERVICE_URL, + service_url=hub_adapter_settings.HUB_SERVICE_URL, response_model=AllProjects, query_params=["filter_id", "filter_realm_id", "filter_user_id", "include"], ) @@ -95,7 +96,7 @@ async def list_all_projects( request_method=hub_router.get, path="/projects/{project_id}", status_code=status.HTTP_200_OK, - service_url=gateway_settings.HUB_SERVICE_URL, + service_url=hub_adapter_settings.HUB_SERVICE_URL, response_model=Project, ) async def list_specific_project( @@ -111,7 +112,7 @@ async def list_specific_project( request_method=hub_router.get, path="/project-nodes", status_code=status.HTTP_200_OK, - service_url=gateway_settings.HUB_SERVICE_URL, + service_url=hub_adapter_settings.HUB_SERVICE_URL, response_model=ListAnalysisOrProjectNodes, query_params=["filter_id", "filter_project_id", "filter_project_realm_id", "filter_node_id", "filter_node_realm_id"], @@ -158,7 +159,7 @@ async def list_projects_and_nodes( request_method=hub_router.post, path="/project-nodes/{project_id}", status_code=status.HTTP_200_OK, - service_url=gateway_settings.HUB_SERVICE_URL, + service_url=hub_adapter_settings.HUB_SERVICE_URL, response_model=AnalysisOrProjectNode, body_params=["approval_status"], ) @@ -178,7 +179,7 @@ async def accept_reject_project_node( request_method=hub_router.get, path="/analysis-nodes", status_code=status.HTTP_200_OK, - service_url=gateway_settings.HUB_SERVICE_URL, + service_url=hub_adapter_settings.HUB_SERVICE_URL, # response_model=ListAnalysisNodes, response_model=ContainerResponse, query_params=["filter_id", "filter_project_id", "filter_project_realm_id", @@ -246,7 +247,7 @@ async def list_analyses_of_nodes( request_method=hub_router.get, path="/analysis-nodes/{analysis_id}", status_code=status.HTTP_200_OK, - service_url=gateway_settings.HUB_SERVICE_URL, + service_url=hub_adapter_settings.HUB_SERVICE_URL, response_model=AnalysisNode, ) async def list_specific_analysis( @@ -262,7 +263,7 @@ async def list_specific_analysis( request_method=hub_router.post, path="/analysis-nodes/{analysis_id}", status_code=status.HTTP_200_OK, - service_url=gateway_settings.HUB_SERVICE_URL, + service_url=hub_adapter_settings.HUB_SERVICE_URL, response_model=AnalysisNode, body_params=["approval_status"], ) diff --git a/gateway/routers/kong.py b/hub_adapter/routers/kong.py similarity index 98% rename from gateway/routers/kong.py rename to hub_adapter/routers/kong.py index 0f54514..ea64713 100644 --- a/gateway/routers/kong.py +++ b/hub_adapter/routers/kong.py @@ -9,9 +9,9 @@ from kong_admin_client.rest import ApiException from starlette import status -from gateway.auth import verify_idp_token, idp_oauth2_scheme_pass, httpbearer -from gateway.conf import gateway_settings -from gateway.models.kong import ServiceRequest, HttpMethodCode, ProtocolCode, LinkDataStoreProject, \ +from hub_adapter.auth import verify_idp_token, idp_oauth2_scheme_pass, httpbearer +from hub_adapter.conf import hub_adapter_settings +from hub_adapter.models.kong import ServiceRequest, HttpMethodCode, ProtocolCode, LinkDataStoreProject, \ Disconnect, LinkProjectAnalysis kong_router = APIRouter( @@ -22,7 +22,7 @@ ) logger = logging.getLogger(__name__) -kong_admin_url = gateway_settings.KONG_ADMIN_SERVICE_URL +kong_admin_url = hub_adapter_settings.KONG_ADMIN_SERVICE_URL @kong_router.get("/datastore", response_model=ListRoute200Response, status_code=status.HTTP_200_OK) diff --git a/gateway/routers/metadata.py b/hub_adapter/routers/metadata.py similarity index 77% rename from gateway/routers/metadata.py rename to hub_adapter/routers/metadata.py index 9ae2865..dc6f125 100644 --- a/gateway/routers/metadata.py +++ b/hub_adapter/routers/metadata.py @@ -2,8 +2,8 @@ from fastapi import APIRouter -from gateway.conf import gateway_settings -from gateway.models.conf import KeycloakConfig +from hub_adapter.conf import hub_adapter_settings +from hub_adapter.models.conf import KeycloakConfig metadata_router = APIRouter( # dependencies=[Security(oauth2_scheme)], @@ -16,8 +16,8 @@ async def get_keycloak_config(): """Return keycloak metadata for the frontend.""" return { - "realm": gateway_settings.IDP_REALM, - "url": gateway_settings.IDP_URL, + "realm": hub_adapter_settings.IDP_REALM, + "url": hub_adapter_settings.IDP_URL, "clientId": "node-ui-app", } diff --git a/gateway/routers/podorc.py b/hub_adapter/routers/podorc.py similarity index 83% rename from gateway/routers/podorc.py rename to hub_adapter/routers/podorc.py index c8a8ebe..115377c 100644 --- a/gateway/routers/podorc.py +++ b/hub_adapter/routers/podorc.py @@ -7,9 +7,9 @@ from starlette.requests import Request from starlette.responses import Response -from gateway.auth import verify_idp_token, idp_oauth2_scheme_pass, httpbearer -from gateway.conf import gateway_settings -from gateway.core import route +from hub_adapter.auth import verify_idp_token, idp_oauth2_scheme_pass, httpbearer +from hub_adapter.conf import hub_adapter_settings +from hub_adapter.core import route po_router = APIRouter( dependencies=[Security(verify_idp_token), Security(idp_oauth2_scheme_pass), Security(httpbearer)], @@ -24,7 +24,7 @@ request_method=po_router.post, path="/po", status_code=status.HTTP_200_OK, - service_url=gateway_settings.PODORC_SERVICE_URL, + service_url=hub_adapter_settings.PODORC_SERVICE_URL, body_params=["analysis_id", "project_id"], ) async def create_analysis( @@ -41,7 +41,7 @@ async def create_analysis( request_method=po_router.get, path="/po/{analysis_id}/logs", status_code=status.HTTP_200_OK, - service_url=gateway_settings.PODORC_SERVICE_URL, + service_url=hub_adapter_settings.PODORC_SERVICE_URL, ) async def get_analysis_logs( request: Request, @@ -56,7 +56,7 @@ async def get_analysis_logs( request_method=po_router.get, path="/po/{analysis_id}/status", status_code=status.HTTP_200_OK, - service_url=gateway_settings.PODORC_SERVICE_URL, + service_url=hub_adapter_settings.PODORC_SERVICE_URL, ) async def get_analysis_status( request: Request, @@ -71,7 +71,7 @@ async def get_analysis_status( request_method=po_router.get, path="/po/{analysis_id}/pods", status_code=status.HTTP_200_OK, - service_url=gateway_settings.PODORC_SERVICE_URL, + service_url=hub_adapter_settings.PODORC_SERVICE_URL, ) async def get_analysis_pods( request: Request, @@ -86,7 +86,7 @@ async def get_analysis_pods( request_method=po_router.put, path="/po/{analysis_id}/stop", status_code=status.HTTP_200_OK, - service_url=gateway_settings.PODORC_SERVICE_URL, + service_url=hub_adapter_settings.PODORC_SERVICE_URL, ) async def stop_analysis( request: Request, @@ -101,7 +101,7 @@ async def stop_analysis( request_method=po_router.delete, path="/po/{analysis_id}/delete", status_code=status.HTTP_200_OK, - service_url=gateway_settings.PODORC_SERVICE_URL, + service_url=hub_adapter_settings.PODORC_SERVICE_URL, ) async def delete_analysis( request: Request, diff --git a/gateway/routers/results.py b/hub_adapter/routers/results.py similarity index 76% rename from gateway/routers/results.py rename to hub_adapter/routers/results.py index faac307..eb813e6 100644 --- a/gateway/routers/results.py +++ b/hub_adapter/routers/results.py @@ -6,10 +6,10 @@ from starlette.requests import Request from starlette.responses import Response -from gateway.auth import verify_idp_token, idp_oauth2_scheme_pass, httpbearer -from gateway.conf import gateway_settings -from gateway.core import route -from gateway.models.results import ResultsUploadResponse +from hub_adapter.auth import verify_idp_token, idp_oauth2_scheme_pass, httpbearer +from hub_adapter.conf import hub_adapter_settings +from hub_adapter.core import route +from hub_adapter.models.results import ResultsUploadResponse results_router = APIRouter( dependencies=[Security(verify_idp_token), Security(idp_oauth2_scheme_pass), Security(httpbearer)], @@ -22,7 +22,7 @@ request_method=results_router.get, path="/scratch/{object_id}", status_code=status.HTTP_200_OK, - service_url=gateway_settings.RESULTS_SERVICE_URL, + service_url=hub_adapter_settings.RESULTS_SERVICE_URL, response_model=None, file_response=True, ) @@ -38,7 +38,7 @@ async def read_from_scratch( request_method=results_router.put, path="/scratch", status_code=status.HTTP_200_OK, - service_url=gateway_settings.RESULTS_SERVICE_URL, + service_url=hub_adapter_settings.RESULTS_SERVICE_URL, response_model=ResultsUploadResponse, file_params=["file"], ) @@ -54,7 +54,7 @@ async def upload_to_scratch( request_method=results_router.put, path="/upload", status_code=status.HTTP_200_OK, - service_url=gateway_settings.RESULTS_SERVICE_URL, + service_url=hub_adapter_settings.RESULTS_SERVICE_URL, response_model=ResultsUploadResponse, file_params=["file"], ) diff --git a/gateway/server.py b/hub_adapter/server.py similarity index 80% rename from gateway/server.py rename to hub_adapter/server.py index 2a5f7ee..7fcc992 100644 --- a/gateway/server.py +++ b/hub_adapter/server.py @@ -1,8 +1,4 @@ """Methods for verifying auth.""" -import json -import logging.config -from contextlib import asynccontextmanager -from pathlib import Path from typing import Annotated import httpx @@ -12,30 +8,14 @@ from starlette import status from starlette.middleware.cors import CORSMiddleware -from gateway.auth import realm_idp_settings -from gateway.models.conf import Token -from gateway.routers.health import health_router -from gateway.routers.hub import hub_router -from gateway.routers.kong import kong_router -from gateway.routers.metadata import metadata_router -from gateway.routers.podorc import po_router -from gateway.routers.results import results_router - - -@asynccontextmanager -async def lifespan(app: FastAPI): - """Actions for lifespan of API.""" - root_dir = Path.cwd().parent - root_dir.joinpath("logs").mkdir(parents=True, exist_ok=True) - - log_config_path = root_dir.joinpath("logging.json") - with open(log_config_path, "r") as logf: - log_config = json.load(logf) - - logging.config.dictConfig(log_config) - - yield - +from hub_adapter.auth import realm_idp_settings +from hub_adapter.models.conf import Token +from hub_adapter.routers.health import health_router +from hub_adapter.routers.hub import hub_router +from hub_adapter.routers.kong import kong_router +from hub_adapter.routers.metadata import metadata_router +from hub_adapter.routers.podorc import po_router +from hub_adapter.routers.results import results_router # API metadata tags_metadata = [ @@ -56,7 +36,6 @@ async def lifespan(app: FastAPI): # Auth fill client ID for the docs with the below value "clientId": realm_idp_settings.client_id, # default client-id is Keycloak }, - lifespan=lifespan, license_info={ "name": "Apache 2.0", "url": "https://www.apache.org/licenses/LICENSE-2.0.html", diff --git a/gateway/utils.py b/hub_adapter/utils.py similarity index 100% rename from gateway/utils.py rename to hub_adapter/utils.py diff --git a/logging.json b/logging.json deleted file mode 100644 index 1ecd4e6..0000000 --- a/logging.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "version": 1, - "disable_existing_loggers": false, - "formatters": { - "simple": { - "format": "%(levelname)s: %(message)s" - }, - "detailed": { - "format": "%(levelname)s - %(module)s:L%(lineno)d - %(asctime)s - %(message)s", - "datefmt": "%Y-%m-%dT%H:%M:%S%z" - } - }, - "handlers": { - "stderr": { - "class": "logging.StreamHandler", - "level": "WARNING", - "formatter": "simple", - "stream": "ext://sys.stderr" - }, - "file": { - "class": "logging.handlers.RotatingFileHandler", - "level": "DEBUG", - "formatter": "detailed", - "filename": "../logs/node_hub_api_adapter.log", - "maxBytes": 1000000, - "backupCount": 5 - } - }, - "loggers": { - "gateway": { - "level": "DEBUG", - "handlers": [ - "stderr", - "file" - ] - } - } -} diff --git a/poetry.lock b/poetry.lock index f086e6e..8382a9c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -379,7 +379,7 @@ files = [ ] [[package]] -name = "kong-admin-client" +name = "kongadminclient" version = "3.5.0" description = "Kong Admin API" optional = false @@ -1011,4 +1011,4 @@ test = ["websockets"] [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "8914a03bb472db5fb33fbba028fa6de3efbef62b306fd872e5bf3602fdd81db3" +content-hash = "114204d063718302469606d48ca9c2ea809bc87de0f88354c151c796926cca17" diff --git a/pyproject.toml b/pyproject.toml index e3e8ccd..73cda26 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,11 @@ [tool.poetry] -name = "flame-gateway" +name = "hub-adapter" version = "0.1.0" description = "API gateway interface for the Node UI to interact with the other node services and the hub." authors = ["Bruce Schultz "] readme = "README.md" license = "Apache 2.0" -packages = [{ include = "gateway" }] +packages = [{ include = "hub_adapter" }] [tool.poetry.dependencies] python = "^3.11" @@ -17,7 +17,7 @@ kubernetes = "^29.0.0" click = "^8.1.7" python-multipart = "^0.0.9" httpx = "^0.27.0" -kong-admin-client = { git = "https://github.com/PrivateAIM/kong-admin-python-client.git" } +kongadminclient = { git = "https://github.com/PrivateAIM/kong-admin-python-client.git" } python-dotenv = "^1.0.1" [tool.poetry.group.dev.dependencies] @@ -30,4 +30,4 @@ requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" [tool.poetry.scripts] -flame-gateway = "gateway.cli:main" +hub-adapter = "hub_adapter.cli:main" diff --git a/tests/conftest.py b/tests/conftest.py index 85654de..549805d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -6,8 +6,8 @@ import pytest from fastapi.testclient import TestClient -from gateway.conf import gateway_settings -from gateway.server import app +from hub_adapter.conf import hub_adapter_settings +from hub_adapter.server import app from tests.constants import TEST_DS, TEST_PROJECT, TEST_ANALYSIS from tests.pseudo_auth import BearerAuth @@ -35,7 +35,7 @@ def hub_token() -> BearerAuth: """Create an endpoint by which to test the valid JWKS.""" # TODO: replace with robot account hub_username, hub_password = os.getenv("HUB_USERNAME"), os.getenv("HUB_PASSWORD") - hub_auth_api = gateway_settings.HUB_AUTH_SERVICE_URL + hub_auth_api = hub_adapter_settings.HUB_AUTH_SERVICE_URL hub_token_ep = hub_auth_api + "/token" resp = httpx.post(hub_token_ep, data={"username": hub_username, "password": hub_password})