Skip to content

Commit

Permalink
feat(kong): add kong endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
brucetony committed Mar 12, 2024
1 parent 5ee95f3 commit c18d156
Show file tree
Hide file tree
Showing 8 changed files with 477 additions and 20 deletions.
2 changes: 1 addition & 1 deletion gateway/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Settings(BaseModel):
# Service URLs
RESULTS_SERVICE_URL: str = os.getenv("RESULTS_SERVICE_URL", "http://localhost:8000")
PODORC_SERVICE_URL: str = os.getenv("PODORC_SERVICE_URL")
KONG_SERVICE_URL: str = os.getenv("RESULTS_SERVICE_URL", "http://localhost:8000")
KONG_ADMIN_SERVICE_URL: str = os.getenv("RESULTS_SERVICE_URL", "http://localhost:8001")

# UI ID and secret
UI_CLIENT_ID: str = os.getenv("UI_CLIENT_ID", "test-client")
Expand Down
1 change: 1 addition & 0 deletions gateway/models/k8s.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Endpoints for the pod orchestrator."""
from typing import Optional
from uuid import UUID

Expand Down
51 changes: 51 additions & 0 deletions gateway/models/kong.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""Models for the Kong microservice."""
from enum import Enum

from kong_admin_client import CreateServiceRequest, CreateServiceRequestClientCertificate, Plugin, Consumer, KeyAuth, \
ACL
from kong_admin_client.models.service import Service
from pydantic import BaseModel, constr


class DataStoreType(Enum):
"""Data store types."""
S3: str = "s3"
FHIR: str = "fhir"


class Services(BaseModel):
"""Data store list response model."""
data: list[Service]
offset: int | None = None


class ServiceRequest(CreateServiceRequest):
"""Improved version of the CreateServiceRequest with better defaults."""
protocol: str | None = "http"
port: int | None = 80
path: str | None = "/somewhere"
client_certificate: CreateServiceRequestClientCertificate | None = None
tls_verify: bool | None = None
ca_certificates: list[str] | None = None


class LinkDataStoreProject(BaseModel):
route: Service
keyauth: Plugin
acl: Plugin


class LinkProjectAnalysis(BaseModel):
consumer: Consumer
keyauth: KeyAuth
acl: ACL


class Disconnect(BaseModel):
"""Response from disconnecting a project from a datastore."""
removed_routes: list[str] | None
status: str | None


HttpMethodCode = constr(pattern=r"(GET|POST|PUT|PATCH|DELETE|OPTIONS|HEAD|CONNECT|TRACE|CUSTOM)")
ProtocolCode = constr(pattern=r"(http|grpc|grpcs|tls|tcp)")
5 changes: 3 additions & 2 deletions gateway/routers/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
from gateway.auth import hub_oauth2_scheme
from gateway.conf import gateway_settings
from gateway.core import route
from gateway.models import ImageDataResponse, ContainerResponse, Project, AllProjects, \
ApprovalStatus, AnalysisOrProjectNode, ListAnalysisNodes, ListAnalysisOrProjectNodes, AnalysisNode
from gateway.models.hub import Project, AllProjects, ApprovalStatus, AnalysisOrProjectNode, ListAnalysisNodes, \
ListAnalysisOrProjectNodes, AnalysisNode
from gateway.models.k8s import ImageDataResponse, ContainerResponse

hub_router = APIRouter(
dependencies=[Security(hub_oauth2_scheme)],
Expand Down
1 change: 1 addition & 0 deletions gateway/routers/k8s.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""EPs for the pod orchestrator."""
import logging
from typing import Annotated

Expand Down
Loading

0 comments on commit c18d156

Please sign in to comment.