port-ocean 0.12.6__tar.gz → 0.12.7.dev1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of port-ocean might be problematic. Click here for more details.
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/PKG-INFO +1 -1
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/context/ocean.py +2 -2
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/event_listener/http.py +4 -5
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/exceptions/api.py +1 -1
- port_ocean-0.12.7.dev1/port_ocean/middlewares.py +70 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/ocean.py +25 -12
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/tests/helpers/ocean_app.py +5 -2
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/pyproject.toml +1 -1
- port_ocean-0.12.6/port_ocean/middlewares.py +0 -73
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/LICENSE.md +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/README.md +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/bootstrap.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cli.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/commands/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/commands/defaults/__init___.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/commands/defaults/clean.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/commands/defaults/dock.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/commands/defaults/group.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/commands/list_integrations.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/commands/main.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/commands/new.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/commands/pull.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/commands/sail.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/commands/version.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cookiecutter/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cookiecutter/cookiecutter.json +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cookiecutter/extensions.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cookiecutter/hooks/post_gen_project.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.dockerignore +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.env.example +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.gitignore +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.port/resources/.gitignore +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.port/resources/blueprints.json +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.port/resources/port-app-config.yml +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.port/spec.yaml +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/CHANGELOG.md +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/CONTRIBUTING.md +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/Dockerfile +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/README.md +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/changelog/.gitignore +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/debug.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/main.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/poetry.toml +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/pyproject.toml +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/sonar-project.properties +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/tests/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/tests/test_sample.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/utils.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/clients/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/clients/port/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/clients/port/authentication.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/clients/port/client.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/clients/port/mixins/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/clients/port/mixins/blueprints.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/clients/port/mixins/entities.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/clients/port/mixins/integrations.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/clients/port/mixins/migrations.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/clients/port/retry_transport.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/clients/port/types.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/clients/port/utils.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/config/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/config/base.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/config/dynamic.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/config/settings.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/consumers/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/consumers/kafka_consumer.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/context/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/context/event.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/context/resource.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/defaults/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/defaults/clean.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/defaults/common.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/defaults/initialize.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/event_listener/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/event_listener/base.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/event_listener/factory.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/event_listener/kafka.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/event_listener/once.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/event_listener/polling.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/handlers/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/handlers/base.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/handlers/entities_state_applier/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/handlers/entities_state_applier/base.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/handlers/entities_state_applier/port/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/handlers/entities_state_applier/port/applier.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/handlers/entities_state_applier/port/get_related_entities.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/handlers/entities_state_applier/port/order_by_entities_dependencies.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/handlers/entity_processor/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/handlers/entity_processor/base.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/handlers/entity_processor/jq_entity_processor.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/handlers/port_app_config/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/handlers/port_app_config/api.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/handlers/port_app_config/base.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/handlers/port_app_config/models.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/handlers/resync_state_updater/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/handlers/resync_state_updater/updater.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/integrations/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/integrations/base.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/integrations/mixins/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/integrations/mixins/events.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/integrations/mixins/handler.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/integrations/mixins/sync.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/integrations/mixins/sync_raw.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/integrations/mixins/utils.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/models.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/ocean_types.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/utils.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/exceptions/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/exceptions/base.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/exceptions/clients.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/exceptions/context.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/exceptions/core.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/exceptions/port_defaults.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/exceptions/utils.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/helpers/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/helpers/async_client.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/helpers/retry.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/log/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/log/handlers.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/log/logger_setup.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/log/sensetive.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/py.typed +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/run.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/sonar-project.properties +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/tests/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/tests/clients/port/mixins/test_entities.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/tests/conftest.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/tests/core/handlers/entity_processor/test_jq_entity_processor.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/tests/helpers/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/tests/helpers/fixtures.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/tests/helpers/integration.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/tests/helpers/port_client.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/tests/helpers/smoke_test.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/tests/test_smoke.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/tests/utils/test_async_iterators.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/utils/__init__.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/utils/async_http.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/utils/async_iterators.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/utils/cache.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/utils/misc.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/utils/queue_utils.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/utils/repeat.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/utils/signal.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/utils/time.py +0 -0
- {port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/version.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from typing import Callable, TYPE_CHECKING, Any, Literal, Union
|
|
2
2
|
|
|
3
|
-
from fastapi import APIRouter
|
|
4
3
|
from pydantic.main import BaseModel
|
|
4
|
+
from starlette.routing import Router
|
|
5
5
|
from werkzeug.local import LocalProxy
|
|
6
6
|
|
|
7
7
|
from port_ocean.clients.port.types import UserAgentType
|
|
@@ -45,7 +45,7 @@ class PortOceanContext:
|
|
|
45
45
|
return self.app.config
|
|
46
46
|
|
|
47
47
|
@property
|
|
48
|
-
def router(self) ->
|
|
48
|
+
def router(self) -> Router:
|
|
49
49
|
return self.app.integration_router
|
|
50
50
|
|
|
51
51
|
@property
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
from typing import Literal, Any
|
|
2
2
|
|
|
3
|
-
from fastapi import APIRouter
|
|
4
3
|
from loguru import logger
|
|
5
4
|
from pydantic import AnyHttpUrl
|
|
6
5
|
from pydantic.fields import Field
|
|
6
|
+
from starlette.requests import Request
|
|
7
|
+
from starlette.routing import Router, Route
|
|
7
8
|
|
|
8
9
|
from port_ocean.context.ocean import ocean
|
|
9
10
|
from port_ocean.core.event_listener.base import (
|
|
@@ -60,10 +61,8 @@ class HttpEventListener(BaseEventListener):
|
|
|
60
61
|
It sets up an APIRouter to handle the `/resync` endpoint and registers the "on_resync" event handler.
|
|
61
62
|
"""
|
|
62
63
|
logger.info("Setting up HTTP Event Listener")
|
|
63
|
-
target_channel_router = APIRouter()
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
async def resync() -> None:
|
|
65
|
+
async def resync(request: Request) -> None:
|
|
67
66
|
await self._resync({})
|
|
68
67
|
|
|
69
|
-
ocean.
|
|
68
|
+
ocean.router.routes.append(Route("/resync", methods=["post"], endpoint=resync))
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from loguru import logger
|
|
2
|
+
from starlette.requests import Request
|
|
3
|
+
from starlette.responses import Response
|
|
4
|
+
|
|
5
|
+
from port_ocean.exceptions.api import BaseAPIException, InternalServerException
|
|
6
|
+
from .context.event import event_context, EventType
|
|
7
|
+
from .context.ocean import ocean
|
|
8
|
+
from .utils.misc import get_time, generate_uuid
|
|
9
|
+
from starlette.middleware.base import (
|
|
10
|
+
BaseHTTPMiddleware,
|
|
11
|
+
RequestResponseEndpoint,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class RequestHandlerMiddleware(BaseHTTPMiddleware):
|
|
16
|
+
async def dispatch(self, request: Request, call_next: RequestResponseEndpoint):
|
|
17
|
+
start_time = get_time(seconds_precision=False)
|
|
18
|
+
request_id = generate_uuid()
|
|
19
|
+
|
|
20
|
+
with logger.contextualize(request_id=request_id):
|
|
21
|
+
log_level = (
|
|
22
|
+
"DEBUG"
|
|
23
|
+
if request.url.path == "/docs" or request.url.path == "/openapi.json"
|
|
24
|
+
else "INFO"
|
|
25
|
+
)
|
|
26
|
+
logger.bind(url=str(request.url), method=request.method).log(
|
|
27
|
+
log_level, f"Request to {request.url.path} started"
|
|
28
|
+
)
|
|
29
|
+
response = await self._handle_silently(request, call_next)
|
|
30
|
+
|
|
31
|
+
end_time = get_time(seconds_precision=False)
|
|
32
|
+
time_elapsed = round(end_time - start_time, 5)
|
|
33
|
+
response.headers["X-Request-ID"] = request_id
|
|
34
|
+
response.headers["X-Process-Time"] = str(time_elapsed)
|
|
35
|
+
logger.bind(
|
|
36
|
+
time_elapsed=time_elapsed, response_status=response.status_code
|
|
37
|
+
).log(log_level, f"Request to {request.url.path} ended")
|
|
38
|
+
|
|
39
|
+
return response
|
|
40
|
+
|
|
41
|
+
async def _handle_silently(
|
|
42
|
+
self, request: Request, call_next: RequestResponseEndpoint
|
|
43
|
+
) -> Response:
|
|
44
|
+
response: Response
|
|
45
|
+
try:
|
|
46
|
+
if request.url.path.startswith("/integration"):
|
|
47
|
+
async with event_context(
|
|
48
|
+
EventType.HTTP_REQUEST, trigger_type="request"
|
|
49
|
+
):
|
|
50
|
+
await ocean.integration.port_app_config_handler.get_port_app_config()
|
|
51
|
+
response = await call_next(request)
|
|
52
|
+
else:
|
|
53
|
+
response = await call_next(request)
|
|
54
|
+
|
|
55
|
+
except BaseAPIException as ex:
|
|
56
|
+
response = ex.response()
|
|
57
|
+
if response.status_code < 500:
|
|
58
|
+
logger.bind(exception=str(ex)).info(
|
|
59
|
+
"Request did not succeed due to client-side error"
|
|
60
|
+
)
|
|
61
|
+
else:
|
|
62
|
+
logger.opt(exception=True).warning(
|
|
63
|
+
"Request did not succeed due to server-side error"
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
except Exception:
|
|
67
|
+
logger.opt(exception=True).error("Request failed due to unexpected error")
|
|
68
|
+
response = InternalServerException().response()
|
|
69
|
+
|
|
70
|
+
return response
|
|
@@ -4,9 +4,13 @@ import threading
|
|
|
4
4
|
from contextlib import asynccontextmanager
|
|
5
5
|
from typing import Callable, Any, Dict, AsyncIterator, Type
|
|
6
6
|
|
|
7
|
-
from fastapi import FastAPI, APIRouter
|
|
8
7
|
from loguru import logger
|
|
9
8
|
from pydantic import BaseModel
|
|
9
|
+
from starlette.applications import Starlette
|
|
10
|
+
from starlette.middleware import Middleware
|
|
11
|
+
from starlette.requests import Request
|
|
12
|
+
from starlette.responses import JSONResponse
|
|
13
|
+
from starlette.routing import Route, Mount, Router
|
|
10
14
|
from starlette.types import Scope, Receive, Send
|
|
11
15
|
|
|
12
16
|
from port_ocean.core.handlers.resync_state_updater import ResyncStateUpdater
|
|
@@ -22,7 +26,7 @@ from port_ocean.context.ocean import (
|
|
|
22
26
|
)
|
|
23
27
|
from port_ocean.core.integrations.base import BaseIntegration
|
|
24
28
|
from port_ocean.log.sensetive import sensitive_log_filter
|
|
25
|
-
from port_ocean.middlewares import
|
|
29
|
+
from port_ocean.middlewares import RequestHandlerMiddleware
|
|
26
30
|
from port_ocean.utils.repeat import repeat_every
|
|
27
31
|
from port_ocean.utils.signal import signal_handler
|
|
28
32
|
from port_ocean.version import __integration_version__
|
|
@@ -32,15 +36,16 @@ from port_ocean.utils.misc import IntegrationStateStatus
|
|
|
32
36
|
class Ocean:
|
|
33
37
|
def __init__(
|
|
34
38
|
self,
|
|
35
|
-
app:
|
|
39
|
+
app: Starlette | None = None,
|
|
36
40
|
integration_class: Callable[[PortOceanContext], BaseIntegration] | None = None,
|
|
37
|
-
integration_router:
|
|
41
|
+
integration_router: Router | None = None,
|
|
38
42
|
config_factory: Type[BaseModel] | None = None,
|
|
39
43
|
config_override: Dict[str, Any] | None = None,
|
|
40
44
|
):
|
|
41
45
|
initialize_port_ocean_context(self)
|
|
42
|
-
|
|
43
|
-
self.
|
|
46
|
+
|
|
47
|
+
self.starlette_app = app or Starlette()
|
|
48
|
+
self.integration_router = integration_router or Router()
|
|
44
49
|
|
|
45
50
|
self.config = IntegrationConfiguration(
|
|
46
51
|
# type: ignore
|
|
@@ -52,7 +57,6 @@ class Ocean:
|
|
|
52
57
|
sensitive_log_filter.hide_sensitive_strings(
|
|
53
58
|
*self.config.get_sensitive_fields_data()
|
|
54
59
|
)
|
|
55
|
-
self.integration_router = integration_router or APIRouter()
|
|
56
60
|
|
|
57
61
|
self.port_client = PortClient(
|
|
58
62
|
base_url=self.config.port.base_url,
|
|
@@ -113,10 +117,8 @@ class Ocean:
|
|
|
113
117
|
await repeated_function()
|
|
114
118
|
|
|
115
119
|
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
|
|
116
|
-
self.fast_api_app.include_router(self.integration_router, prefix="/integration")
|
|
117
|
-
|
|
118
120
|
@asynccontextmanager
|
|
119
|
-
async def
|
|
121
|
+
async def lifespan(_: Starlette) -> AsyncIterator[None]:
|
|
120
122
|
try:
|
|
121
123
|
await self.integration.start()
|
|
122
124
|
await self._setup_scheduled_resync()
|
|
@@ -127,5 +129,16 @@ class Ocean:
|
|
|
127
129
|
finally:
|
|
128
130
|
signal_handler.exit()
|
|
129
131
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
+
async def health(request: Request) -> JSONResponse:
|
|
133
|
+
return JSONResponse({"ok": True})
|
|
134
|
+
|
|
135
|
+
self.starlette_app = Starlette(
|
|
136
|
+
routes=[
|
|
137
|
+
Route("/docs", endpoint=health),
|
|
138
|
+
Mount("/integration", routes=self.integration_router.routes),
|
|
139
|
+
],
|
|
140
|
+
middleware=[Middleware(RequestHandlerMiddleware)],
|
|
141
|
+
lifespan=lifespan,
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
await self.starlette_app(scope, receive, send)
|
|
@@ -6,6 +6,7 @@ from typing import Any, Dict, List, Tuple, Union
|
|
|
6
6
|
from yaml import safe_load
|
|
7
7
|
|
|
8
8
|
from port_ocean.bootstrap import create_default_app
|
|
9
|
+
from port_ocean.config.dynamic import default_config_factory
|
|
9
10
|
from port_ocean.core.handlers.port_app_config.models import ResourceConfig
|
|
10
11
|
from port_ocean.core.ocean_types import RESYNC_RESULT
|
|
11
12
|
from port_ocean.ocean import Ocean
|
|
@@ -16,8 +17,9 @@ def get_integration_ocean_app(
|
|
|
16
17
|
integration_path: str, config_overrides: Union[Dict[str, Any], None] = None
|
|
17
18
|
) -> Ocean:
|
|
18
19
|
spec_file = get_spec_file(Path(integration_path))
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
config_factory = None
|
|
21
|
+
if spec_file is not None:
|
|
22
|
+
config_factory = default_config_factory(spec_file.get("configurations", []))
|
|
21
23
|
|
|
22
24
|
default_app = create_default_app(
|
|
23
25
|
integration_path,
|
|
@@ -32,6 +34,7 @@ def get_integration_ocean_app(
|
|
|
32
34
|
},
|
|
33
35
|
},
|
|
34
36
|
)
|
|
37
|
+
|
|
35
38
|
main_path = f"{integration_path}/main.py"
|
|
36
39
|
sys.path.append(integration_path)
|
|
37
40
|
app_module = load_module(main_path)
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
from typing import Callable, Awaitable
|
|
2
|
-
|
|
3
|
-
from fastapi import Request, Response
|
|
4
|
-
from loguru import logger
|
|
5
|
-
|
|
6
|
-
from port_ocean.exceptions.api import BaseAPIException, InternalServerException
|
|
7
|
-
from .context.event import event_context, EventType
|
|
8
|
-
from .context.ocean import ocean
|
|
9
|
-
from .utils.misc import get_time, generate_uuid
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
async def _handle_silently(
|
|
13
|
-
call_next: Callable[[Request], Awaitable[Response]], request: Request
|
|
14
|
-
) -> Response:
|
|
15
|
-
response: Response
|
|
16
|
-
try:
|
|
17
|
-
if request.url.path.startswith("/integration"):
|
|
18
|
-
async with event_context(EventType.HTTP_REQUEST, trigger_type="request"):
|
|
19
|
-
await ocean.integration.port_app_config_handler.get_port_app_config()
|
|
20
|
-
response = await call_next(request)
|
|
21
|
-
else:
|
|
22
|
-
response = await call_next(request)
|
|
23
|
-
|
|
24
|
-
except BaseAPIException as ex:
|
|
25
|
-
response = ex.response()
|
|
26
|
-
if response.status_code < 500:
|
|
27
|
-
logger.bind(exception=str(ex)).info(
|
|
28
|
-
"Request did not succeed due to client-side error"
|
|
29
|
-
)
|
|
30
|
-
else:
|
|
31
|
-
logger.opt(exception=True).warning(
|
|
32
|
-
"Request did not succeed due to server-side error"
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
except Exception:
|
|
36
|
-
logger.opt(exception=True).error("Request failed due to unexpected error")
|
|
37
|
-
response = InternalServerException().response()
|
|
38
|
-
|
|
39
|
-
return response
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
async def request_handler(
|
|
43
|
-
request: Request, call_next: Callable[[Request], Awaitable[Response]]
|
|
44
|
-
) -> Response:
|
|
45
|
-
"""Middleware used by FastAPI to process each request, featuring:
|
|
46
|
-
|
|
47
|
-
- Contextualize request logs with a unique Request ID (UUID4) for each unique request.
|
|
48
|
-
- Catch exceptions during the request handling. Translate custom API exceptions into responses,
|
|
49
|
-
or treat (and log) unexpected exceptions.
|
|
50
|
-
"""
|
|
51
|
-
start_time = get_time(seconds_precision=False)
|
|
52
|
-
request_id = generate_uuid()
|
|
53
|
-
|
|
54
|
-
with logger.contextualize(request_id=request_id):
|
|
55
|
-
log_level = (
|
|
56
|
-
"DEBUG"
|
|
57
|
-
if request.url.path == "/docs" or request.url.path == "/openapi.json"
|
|
58
|
-
else "INFO"
|
|
59
|
-
)
|
|
60
|
-
logger.bind(url=str(request.url), method=request.method).log(
|
|
61
|
-
log_level, f"Request to {request.url.path} started"
|
|
62
|
-
)
|
|
63
|
-
response = await _handle_silently(call_next, request)
|
|
64
|
-
|
|
65
|
-
end_time = get_time(seconds_precision=False)
|
|
66
|
-
time_elapsed = round(end_time - start_time, 5)
|
|
67
|
-
response.headers["X-Request-ID"] = request_id
|
|
68
|
-
response.headers["X-Process-Time"] = str(time_elapsed)
|
|
69
|
-
logger.bind(
|
|
70
|
-
time_elapsed=time_elapsed, response_status=response.status_code
|
|
71
|
-
).log(log_level, f"Request to {request.url.path} ended")
|
|
72
|
-
|
|
73
|
-
return response
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/cli/cookiecutter/hooks/post_gen_project.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/handlers/entities_state_applier/base.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/handlers/entity_processor/__init__.py
RENAMED
|
File without changes
|
{port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/handlers/entity_processor/base.py
RENAMED
|
File without changes
|
|
File without changes
|
{port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/handlers/port_app_config/__init__.py
RENAMED
|
File without changes
|
{port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/handlers/port_app_config/api.py
RENAMED
|
File without changes
|
{port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/handlers/port_app_config/base.py
RENAMED
|
File without changes
|
{port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/handlers/port_app_config/models.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/integrations/mixins/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/core/integrations/mixins/sync_raw.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{port_ocean-0.12.6 → port_ocean-0.12.7.dev1}/port_ocean/tests/clients/port/mixins/test_entities.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|