port-ocean 0.12.2.dev19__tar.gz → 0.12.2.dev20__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.2.dev19 → port_ocean-0.12.2.dev20}/PKG-INFO +1 -1
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/context/ocean.py +0 -5
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/exceptions/api.py +1 -1
- port_ocean-0.12.2.dev20/port_ocean/middlewares.py +70 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/ocean.py +32 -25
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/pyproject.toml +1 -1
- port_ocean-0.12.2.dev19/port_ocean/middlewares.py +0 -73
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/LICENSE.md +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/README.md +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/bootstrap.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cli.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/commands/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/commands/defaults/__init___.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/commands/defaults/clean.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/commands/defaults/dock.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/commands/defaults/group.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/commands/list_integrations.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/commands/main.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/commands/new.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/commands/pull.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/commands/sail.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/commands/version.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/cookiecutter.json +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/extensions.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/hooks/post_gen_project.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.dockerignore +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.env.example +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.gitignore +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.port/resources/.gitignore +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.port/resources/blueprints.json +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.port/resources/port-app-config.yml +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.port/spec.yaml +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/CHANGELOG.md +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/CONTRIBUTING.md +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/Dockerfile +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/README.md +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/changelog/.gitignore +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/debug.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/main.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/poetry.toml +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/pyproject.toml +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/sonar-project.properties +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/tests/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/tests/test_sample.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/utils.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/clients/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/clients/port/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/clients/port/authentication.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/clients/port/client.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/clients/port/mixins/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/clients/port/mixins/blueprints.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/clients/port/mixins/entities.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/clients/port/mixins/integrations.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/clients/port/mixins/migrations.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/clients/port/retry_transport.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/clients/port/types.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/clients/port/utils.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/config/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/config/base.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/config/dynamic.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/config/settings.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/consumers/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/consumers/kafka_consumer.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/context/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/context/event.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/context/resource.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/defaults/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/defaults/clean.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/defaults/common.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/defaults/initialize.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/event_listener/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/event_listener/base.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/event_listener/factory.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/event_listener/http.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/event_listener/kafka.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/event_listener/once.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/event_listener/polling.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/handlers/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/handlers/base.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/handlers/entities_state_applier/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/handlers/entities_state_applier/base.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/handlers/entities_state_applier/port/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/handlers/entities_state_applier/port/applier.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/handlers/entities_state_applier/port/get_related_entities.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/handlers/entities_state_applier/port/order_by_entities_dependencies.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/handlers/entity_processor/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/handlers/entity_processor/base.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/handlers/entity_processor/jq_entity_processor.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/handlers/port_app_config/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/handlers/port_app_config/api.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/handlers/port_app_config/base.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/handlers/port_app_config/models.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/handlers/resync_state_updater/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/handlers/resync_state_updater/updater.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/integrations/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/integrations/base.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/integrations/mixins/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/integrations/mixins/events.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/integrations/mixins/handler.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/integrations/mixins/sync.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/integrations/mixins/sync_raw.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/integrations/mixins/utils.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/models.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/ocean_types.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/utils.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/exceptions/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/exceptions/base.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/exceptions/clients.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/exceptions/context.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/exceptions/core.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/exceptions/port_defaults.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/exceptions/utils.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/helpers/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/helpers/async_client.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/helpers/retry.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/log/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/log/handlers.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/log/logger_setup.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/log/sensetive.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/py.typed +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/run.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/sonar-project.properties +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/tests/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/tests/clients/port/mixins/test_entities.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/tests/conftest.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/tests/core/handlers/entity_processor/test_jq_entity_processor.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/tests/helpers/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/tests/helpers/fixtures.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/tests/helpers/integration.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/tests/helpers/ocean_app.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/tests/helpers/port_client.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/tests/helpers/smoke_test.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/tests/test_smoke.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/utils/__init__.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/utils/async_http.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/utils/async_iterators.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/utils/cache.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/utils/misc.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/utils/queue_utils.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/utils/repeat.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/utils/signal.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/utils/time.py +0 -0
- {port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/version.py +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
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
|
|
5
4
|
from werkzeug.local import LocalProxy
|
|
6
5
|
|
|
@@ -44,10 +43,6 @@ class PortOceanContext:
|
|
|
44
43
|
def config(self) -> "IntegrationConfiguration":
|
|
45
44
|
return self.app.config
|
|
46
45
|
|
|
47
|
-
@property
|
|
48
|
-
def router(self) -> APIRouter:
|
|
49
|
-
return self.app.integration_router
|
|
50
|
-
|
|
51
46
|
@property
|
|
52
47
|
def integration(self) -> "BaseIntegration":
|
|
53
48
|
return self.app.integration
|
|
@@ -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
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import sys
|
|
3
3
|
import threading
|
|
4
|
-
from
|
|
5
|
-
from typing import Callable, Any, Dict, AsyncIterator, Type
|
|
4
|
+
from typing import Callable, Any, Dict, Type
|
|
6
5
|
|
|
7
|
-
from fastapi import FastAPI, APIRouter
|
|
8
6
|
from loguru import logger
|
|
9
7
|
from pydantic import BaseModel
|
|
8
|
+
from starlette.middleware import Middleware
|
|
9
|
+
from starlette.responses import JSONResponse
|
|
10
|
+
from starlette.routing import Route
|
|
10
11
|
from starlette.types import Scope, Receive, Send
|
|
11
12
|
|
|
12
13
|
from port_ocean.clients.port.client import PortClient
|
|
@@ -22,24 +23,46 @@ from port_ocean.core.handlers.resync_state_updater import ResyncStateUpdater
|
|
|
22
23
|
from port_ocean.core.integrations.base import BaseIntegration
|
|
23
24
|
from port_ocean.core.models import Runtime
|
|
24
25
|
from port_ocean.log.sensetive import sensitive_log_filter
|
|
25
|
-
from port_ocean.middlewares import
|
|
26
|
+
from port_ocean.middlewares import RequestHandlerMiddleware
|
|
26
27
|
from port_ocean.utils.repeat import repeat_every
|
|
27
28
|
from port_ocean.utils.signal import signal_handler
|
|
28
29
|
from port_ocean.version import __integration_version__
|
|
30
|
+
import contextlib
|
|
31
|
+
|
|
32
|
+
from starlette.applications import Starlette
|
|
29
33
|
|
|
30
34
|
|
|
31
35
|
class Ocean:
|
|
32
36
|
def __init__(
|
|
33
37
|
self,
|
|
34
|
-
app:
|
|
38
|
+
app: Starlette | None = None,
|
|
35
39
|
integration_class: Callable[[PortOceanContext], BaseIntegration] | None = None,
|
|
36
|
-
integration_router:
|
|
40
|
+
integration_router: None = None,
|
|
37
41
|
config_factory: Type[BaseModel] | None = None,
|
|
38
42
|
config_override: Dict[str, Any] | None = None,
|
|
39
43
|
):
|
|
40
44
|
initialize_port_ocean_context(self)
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
|
|
46
|
+
@contextlib.asynccontextmanager
|
|
47
|
+
async def lifespan(app):
|
|
48
|
+
try:
|
|
49
|
+
await self.integration.start()
|
|
50
|
+
await self._setup_scheduled_resync()
|
|
51
|
+
yield None
|
|
52
|
+
except Exception:
|
|
53
|
+
logger.exception("Integration had a fatal error. Shutting down.")
|
|
54
|
+
sys.exit("Server stopped")
|
|
55
|
+
finally:
|
|
56
|
+
signal_handler.exit()
|
|
57
|
+
|
|
58
|
+
async def handle_webhook_request(data: dict[str, Any]) -> dict[str, Any]:
|
|
59
|
+
return JSONResponse({"ok": True})
|
|
60
|
+
|
|
61
|
+
self.starlette_app = Starlette(
|
|
62
|
+
routes=[Route("/integration/webhook", endpoint=handle_webhook_request)],
|
|
63
|
+
middleware=[Middleware(RequestHandlerMiddleware)],
|
|
64
|
+
lifespan=lifespan,
|
|
65
|
+
)
|
|
43
66
|
|
|
44
67
|
self.config = IntegrationConfiguration(
|
|
45
68
|
# type: ignore
|
|
@@ -51,7 +74,6 @@ class Ocean:
|
|
|
51
74
|
sensitive_log_filter.hide_sensitive_strings(
|
|
52
75
|
*self.config.get_sensitive_fields_data()
|
|
53
76
|
)
|
|
54
|
-
self.integration_router = integration_router or APIRouter()
|
|
55
77
|
|
|
56
78
|
self.port_client = PortClient(
|
|
57
79
|
base_url=self.config.port.base_url,
|
|
@@ -112,19 +134,4 @@ class Ocean:
|
|
|
112
134
|
await repeated_function()
|
|
113
135
|
|
|
114
136
|
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
|
|
115
|
-
self.
|
|
116
|
-
|
|
117
|
-
@asynccontextmanager
|
|
118
|
-
async def lifecycle(_: FastAPI) -> AsyncIterator[None]:
|
|
119
|
-
try:
|
|
120
|
-
await self.integration.start()
|
|
121
|
-
await self._setup_scheduled_resync()
|
|
122
|
-
yield None
|
|
123
|
-
except Exception:
|
|
124
|
-
logger.exception("Integration had a fatal error. Shutting down.")
|
|
125
|
-
sys.exit("Server stopped")
|
|
126
|
-
finally:
|
|
127
|
-
signal_handler.exit()
|
|
128
|
-
|
|
129
|
-
self.fast_api_app.router.lifespan_context = lifecycle
|
|
130
|
-
await self.fast_api_app(scope, receive, send)
|
|
137
|
+
await self.starlette_app(scope, receive, send)
|
|
@@ -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
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/commands/defaults/__init___.py
RENAMED
|
File without changes
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/commands/defaults/clean.py
RENAMED
|
File without changes
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/commands/defaults/dock.py
RENAMED
|
File without changes
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/commands/defaults/group.py
RENAMED
|
File without changes
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/commands/list_integrations.py
RENAMED
|
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.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/cookiecutter.json
RENAMED
|
File without changes
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/cli/cookiecutter/extensions.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
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/clients/port/authentication.py
RENAMED
|
File without changes
|
|
File without changes
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/clients/port/mixins/__init__.py
RENAMED
|
File without changes
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/clients/port/mixins/blueprints.py
RENAMED
|
File without changes
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/clients/port/mixins/entities.py
RENAMED
|
File without changes
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/clients/port/mixins/integrations.py
RENAMED
|
File without changes
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/clients/port/mixins/migrations.py
RENAMED
|
File without changes
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/clients/port/retry_transport.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
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/event_listener/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/event_listener/factory.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/event_listener/polling.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
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/handlers/port_app_config/api.py
RENAMED
|
File without changes
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/handlers/port_app_config/base.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/integrations/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/integrations/mixins/__init__.py
RENAMED
|
File without changes
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/integrations/mixins/events.py
RENAMED
|
File without changes
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/integrations/mixins/handler.py
RENAMED
|
File without changes
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/integrations/mixins/sync.py
RENAMED
|
File without changes
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/integrations/mixins/sync_raw.py
RENAMED
|
File without changes
|
{port_ocean-0.12.2.dev19 → port_ocean-0.12.2.dev20}/port_ocean/core/integrations/mixins/utils.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
|