port-ocean 0.5.27__py3-none-any.whl → 0.6.0__py3-none-any.whl
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/clients/port/mixins/integrations.py +5 -32
- port_ocean/core/defaults/initialize.py +63 -24
- port_ocean/core/integrations/base.py +0 -6
- port_ocean/run.py +1 -4
- {port_ocean-0.5.27.dist-info → port_ocean-0.6.0.dist-info}/METADATA +1 -1
- {port_ocean-0.5.27.dist-info → port_ocean-0.6.0.dist-info}/RECORD +9 -9
- {port_ocean-0.5.27.dist-info → port_ocean-0.6.0.dist-info}/LICENSE.md +0 -0
- {port_ocean-0.5.27.dist-info → port_ocean-0.6.0.dist-info}/WHEEL +0 -0
- {port_ocean-0.5.27.dist-info → port_ocean-0.6.0.dist-info}/entry_points.txt +0 -0
|
@@ -3,7 +3,6 @@ from urllib.parse import quote_plus
|
|
|
3
3
|
|
|
4
4
|
import httpx
|
|
5
5
|
from loguru import logger
|
|
6
|
-
from starlette import status
|
|
7
6
|
|
|
8
7
|
from port_ocean.clients.port.authentication import PortAuthentication
|
|
9
8
|
from port_ocean.clients.port.utils import handle_status_code
|
|
@@ -44,7 +43,7 @@ class IntegrationClientMixin:
|
|
|
44
43
|
) -> dict[str, Any]:
|
|
45
44
|
response = await self._get_current_integration()
|
|
46
45
|
handle_status_code(response, should_raise, should_log)
|
|
47
|
-
return response.json()
|
|
46
|
+
return response.json().get("integration", {})
|
|
48
47
|
|
|
49
48
|
async def get_log_attributes(self) -> LogAttributes:
|
|
50
49
|
if self._log_attributes is None:
|
|
@@ -57,7 +56,7 @@ class IntegrationClientMixin:
|
|
|
57
56
|
_type: str,
|
|
58
57
|
changelog_destination: dict[str, Any],
|
|
59
58
|
port_app_config: Optional["PortAppConfig"] = None,
|
|
60
|
-
) ->
|
|
59
|
+
) -> dict:
|
|
61
60
|
logger.info(f"Creating integration with id: {self.integration_identifier}")
|
|
62
61
|
headers = await self.auth.headers()
|
|
63
62
|
json = {
|
|
@@ -73,13 +72,14 @@ class IntegrationClientMixin:
|
|
|
73
72
|
f"{self.auth.api_url}/integration", headers=headers, json=json
|
|
74
73
|
)
|
|
75
74
|
handle_status_code(response)
|
|
75
|
+
return response.json()["integration"]
|
|
76
76
|
|
|
77
77
|
async def patch_integration(
|
|
78
78
|
self,
|
|
79
79
|
_type: str | None = None,
|
|
80
80
|
changelog_destination: dict[str, Any] | None = None,
|
|
81
81
|
port_app_config: Optional["PortAppConfig"] = None,
|
|
82
|
-
) ->
|
|
82
|
+
) -> dict:
|
|
83
83
|
logger.info(f"Updating integration with id: {self.integration_identifier}")
|
|
84
84
|
headers = await self.auth.headers()
|
|
85
85
|
json: dict[str, Any] = {}
|
|
@@ -97,34 +97,7 @@ class IntegrationClientMixin:
|
|
|
97
97
|
json=json,
|
|
98
98
|
)
|
|
99
99
|
handle_status_code(response)
|
|
100
|
-
|
|
101
|
-
async def initialize_integration(
|
|
102
|
-
self,
|
|
103
|
-
_type: str,
|
|
104
|
-
changelog_destination: dict[str, Any],
|
|
105
|
-
port_app_config: Optional["PortAppConfig"] = None,
|
|
106
|
-
) -> None:
|
|
107
|
-
logger.info(f"Initiating integration with id: {self.integration_identifier}")
|
|
108
|
-
response = await self._get_current_integration()
|
|
109
|
-
if response.status_code == status.HTTP_404_NOT_FOUND:
|
|
110
|
-
await self.create_integration(_type, changelog_destination, port_app_config)
|
|
111
|
-
else:
|
|
112
|
-
handle_status_code(response)
|
|
113
|
-
|
|
114
|
-
integration = response.json()["integration"]
|
|
115
|
-
logger.info("Checking for diff in integration configuration")
|
|
116
|
-
if (
|
|
117
|
-
integration["changelogDestination"] != changelog_destination
|
|
118
|
-
or integration["installationAppType"] != _type
|
|
119
|
-
or integration.get("version") != self.integration_version
|
|
120
|
-
):
|
|
121
|
-
await self.patch_integration(
|
|
122
|
-
_type, changelog_destination, port_app_config
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
logger.info(
|
|
126
|
-
f"Integration with id: {self.integration_identifier} successfully registered"
|
|
127
|
-
)
|
|
100
|
+
return response.json()["integration"]
|
|
128
101
|
|
|
129
102
|
async def ingest_integration_logs(self, logs: list[dict[str, Any]]) -> None:
|
|
130
103
|
logger.debug("Ingesting logs")
|
|
@@ -3,13 +3,15 @@ from typing import Type, Any
|
|
|
3
3
|
|
|
4
4
|
import httpx
|
|
5
5
|
from loguru import logger
|
|
6
|
-
from starlette import status
|
|
7
6
|
|
|
8
7
|
from port_ocean.clients.port.client import PortClient
|
|
9
8
|
from port_ocean.clients.port.types import UserAgentType
|
|
10
9
|
from port_ocean.config.settings import IntegrationConfiguration
|
|
11
10
|
from port_ocean.context.ocean import ocean
|
|
12
|
-
from port_ocean.core.defaults.common import
|
|
11
|
+
from port_ocean.core.defaults.common import (
|
|
12
|
+
Defaults,
|
|
13
|
+
get_port_integration_defaults,
|
|
14
|
+
)
|
|
13
15
|
from port_ocean.core.handlers.port_app_config.models import PortAppConfig
|
|
14
16
|
from port_ocean.core.models import Blueprint
|
|
15
17
|
from port_ocean.core.utils import gather_and_split_errors_from_results
|
|
@@ -50,18 +52,56 @@ def deconstruct_blueprints_to_creation_steps(
|
|
|
50
52
|
)
|
|
51
53
|
|
|
52
54
|
|
|
53
|
-
async def
|
|
55
|
+
async def _initialize_required_integration_settings(
|
|
54
56
|
port_client: PortClient,
|
|
55
|
-
|
|
57
|
+
default_mapping: PortAppConfig,
|
|
56
58
|
integration_config: IntegrationConfiguration,
|
|
57
59
|
) -> None:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
try:
|
|
61
|
+
logger.info("Initializing integration at port")
|
|
62
|
+
integration = await port_client.get_current_integration(
|
|
63
|
+
should_log=False, should_raise=False
|
|
64
|
+
)
|
|
65
|
+
if not integration:
|
|
66
|
+
logger.info(
|
|
67
|
+
"Integration does not exist, Creating new integration with default default mapping"
|
|
68
|
+
)
|
|
69
|
+
integration = await port_client.create_integration(
|
|
70
|
+
integration_config.integration.type,
|
|
71
|
+
integration_config.event_listener.to_request(),
|
|
72
|
+
port_app_config=default_mapping,
|
|
73
|
+
)
|
|
74
|
+
elif not integration["config"]:
|
|
75
|
+
logger.info(
|
|
76
|
+
"Encountered that the integration's mapping is empty, Initializing to default mapping"
|
|
77
|
+
)
|
|
78
|
+
integration = await port_client.patch_integration(
|
|
79
|
+
integration_config.integration.type,
|
|
80
|
+
integration_config.event_listener.to_request(),
|
|
81
|
+
port_app_config=default_mapping,
|
|
82
|
+
)
|
|
83
|
+
except httpx.HTTPStatusError as err:
|
|
84
|
+
logger.error(f"Failed to apply default mapping: {err.response.text}.")
|
|
85
|
+
raise err
|
|
86
|
+
|
|
87
|
+
logger.info("Checking for diff in integration configuration")
|
|
88
|
+
changelog_destination = integration_config.event_listener.to_request().get(
|
|
89
|
+
"changelog_destination"
|
|
90
|
+
)
|
|
91
|
+
if (
|
|
92
|
+
integration["changelogDestination"] != changelog_destination
|
|
93
|
+
or integration["installationAppType"] != integration_config.integration.type
|
|
94
|
+
or integration.get("version") != port_client.integration_version
|
|
95
|
+
):
|
|
96
|
+
await port_client.patch_integration(
|
|
97
|
+
integration_config.integration.type, changelog_destination
|
|
98
|
+
)
|
|
64
99
|
|
|
100
|
+
|
|
101
|
+
async def _create_resources(
|
|
102
|
+
port_client: PortClient,
|
|
103
|
+
defaults: Defaults,
|
|
104
|
+
) -> None:
|
|
65
105
|
creation_stage, *blueprint_patches = deconstruct_blueprints_to_creation_steps(
|
|
66
106
|
defaults.blueprints
|
|
67
107
|
)
|
|
@@ -148,12 +188,6 @@ async def _create_resources(
|
|
|
148
188
|
pages_errors,
|
|
149
189
|
created_pages_identifiers,
|
|
150
190
|
)
|
|
151
|
-
|
|
152
|
-
await port_client.create_integration(
|
|
153
|
-
integration_config.integration.type,
|
|
154
|
-
integration_config.event_listener.to_request(),
|
|
155
|
-
port_app_config=defaults.port_app_config,
|
|
156
|
-
)
|
|
157
191
|
except httpx.HTTPStatusError as err:
|
|
158
192
|
logger.error(
|
|
159
193
|
f"Failed to create resources: {err.response.text}. Rolling back changes..."
|
|
@@ -169,12 +203,20 @@ async def _initialize_defaults(
|
|
|
169
203
|
port_client = ocean.port_client
|
|
170
204
|
defaults = get_port_integration_defaults(config_class)
|
|
171
205
|
if not defaults:
|
|
172
|
-
logger.warning("No defaults found. Skipping...")
|
|
206
|
+
logger.warning("No defaults found. Skipping initialization...")
|
|
173
207
|
return None
|
|
174
208
|
|
|
209
|
+
if defaults.port_app_config:
|
|
210
|
+
await _initialize_required_integration_settings(
|
|
211
|
+
port_client, defaults.port_app_config, integration_config
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
if not integration_config.initialize_port_resources:
|
|
215
|
+
return
|
|
216
|
+
|
|
175
217
|
try:
|
|
176
218
|
logger.info("Found default resources, starting creation process")
|
|
177
|
-
await _create_resources(port_client, defaults
|
|
219
|
+
await _create_resources(port_client, defaults)
|
|
178
220
|
except AbortDefaultCreationError as e:
|
|
179
221
|
logger.warning(
|
|
180
222
|
f"Failed to create resources. Rolling back blueprints : {e.blueprints_to_rollback}"
|
|
@@ -208,9 +250,6 @@ async def _initialize_defaults(
|
|
|
208
250
|
def initialize_defaults(
|
|
209
251
|
config_class: Type[PortAppConfig], integration_config: IntegrationConfiguration
|
|
210
252
|
) -> None:
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
)
|
|
215
|
-
except Exception as e:
|
|
216
|
-
logger.debug(f"Failed to initialize defaults, skipping... Error: {e}")
|
|
253
|
+
asyncio.new_event_loop().run_until_complete(
|
|
254
|
+
_initialize_defaults(config_class, integration_config)
|
|
255
|
+
)
|
|
@@ -66,12 +66,6 @@ class BaseIntegration(SyncRawMixin, SyncMixin):
|
|
|
66
66
|
|
|
67
67
|
await self.initialize_handlers()
|
|
68
68
|
|
|
69
|
-
logger.info("Initializing integration at port")
|
|
70
|
-
await self.context.port_client.initialize_integration(
|
|
71
|
-
self.context.config.integration.type,
|
|
72
|
-
self.context.config.event_listener.to_request(),
|
|
73
|
-
)
|
|
74
|
-
|
|
75
69
|
self.started = True
|
|
76
70
|
|
|
77
71
|
async with event_context(
|
port_ocean/run.py
CHANGED
|
@@ -49,9 +49,6 @@ def run(
|
|
|
49
49
|
if initialize_port_resources is not None:
|
|
50
50
|
app.config.initialize_port_resources = initialize_port_resources
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
initialize_defaults(
|
|
54
|
-
app.integration.AppConfigHandlerClass.CONFIG_CLASS, app.config
|
|
55
|
-
)
|
|
52
|
+
initialize_defaults(app.integration.AppConfigHandlerClass.CONFIG_CLASS, app.config)
|
|
56
53
|
|
|
57
54
|
uvicorn.run(app, host="0.0.0.0", port=application_settings.port)
|
|
@@ -40,7 +40,7 @@ port_ocean/clients/port/client.py,sha256=3GYCM0ZkX3pB6sNoOb-7_6dm0Jr5_vqhflD9ilt
|
|
|
40
40
|
port_ocean/clients/port/mixins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
41
41
|
port_ocean/clients/port/mixins/blueprints.py,sha256=BiqkhvDFdkySWgL1NHI-LAQ9ieZWazZAojPo9E8d7U4,4575
|
|
42
42
|
port_ocean/clients/port/mixins/entities.py,sha256=pMERHqy1keb5w2k2xQsNuyZaKSAZ5ijVA4pzxEbAatY,7365
|
|
43
|
-
port_ocean/clients/port/mixins/integrations.py,sha256=
|
|
43
|
+
port_ocean/clients/port/mixins/integrations.py,sha256=Ro6h9BwLxglQWniCVmfC---4oyGuUxk_Qejswl2t-J8,4841
|
|
44
44
|
port_ocean/clients/port/mixins/migrations.py,sha256=A6896oJF6WbFL2WroyTkMzr12yhVyWqGoq9dtLNSKBY,1457
|
|
45
45
|
port_ocean/clients/port/retry_transport.py,sha256=PtIZOAZ6V-ncpVysRUsPOgt8Sf01QLnTKB5YeKBxkJk,1861
|
|
46
46
|
port_ocean/clients/port/types.py,sha256=nvlgiAq4WH5_F7wQbz_GAWl-faob84LVgIjZ2Ww5mTk,451
|
|
@@ -59,7 +59,7 @@ port_ocean/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
59
59
|
port_ocean/core/defaults/__init__.py,sha256=8qCZg8n06WAdMu9s_FiRtDYLGPGHbOuS60vapeUoAks,142
|
|
60
60
|
port_ocean/core/defaults/clean.py,sha256=S3UAfca-oU89WJKIB4OgGjGjPr0vxBQ2aRZsLTZhQ04,2185
|
|
61
61
|
port_ocean/core/defaults/common.py,sha256=QnLFTkT3yIWIRtLQb7fUvvfe5AfInYJy0q5LjlzHkOw,3553
|
|
62
|
-
port_ocean/core/defaults/initialize.py,sha256=
|
|
62
|
+
port_ocean/core/defaults/initialize.py,sha256=uq7gnsx2uHpWRuyYbQWGrPY6jbjXfmSWGc6myOQ8CVQ,8853
|
|
63
63
|
port_ocean/core/event_listener/__init__.py,sha256=mzJ33wRq0kh60fpVdOHVmvMTUQIvz3vxmifyBgwDn0E,889
|
|
64
64
|
port_ocean/core/event_listener/base.py,sha256=4RujgPz4VfDFlviu4qLGJFnJougSCL-Ewf0rfTQfwgc,1133
|
|
65
65
|
port_ocean/core/event_listener/factory.py,sha256=AYYfSHPAF7P5H-uQECXT0JVJjKDHrYkWJJBSL4mGkg8,3697
|
|
@@ -83,7 +83,7 @@ port_ocean/core/handlers/port_app_config/api.py,sha256=6VbKPwFzsWG0IYsVD81hxSmfq
|
|
|
83
83
|
port_ocean/core/handlers/port_app_config/base.py,sha256=oufdNLzUmEgJY5PgIz75zDlowWrjA-y8WR4UnM58E58,2897
|
|
84
84
|
port_ocean/core/handlers/port_app_config/models.py,sha256=WtF2uW4KPUPfDpy6E2tl9qXh5GUcDucVvKt0DCTYv6w,1985
|
|
85
85
|
port_ocean/core/integrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
86
|
-
port_ocean/core/integrations/base.py,sha256=
|
|
86
|
+
port_ocean/core/integrations/base.py,sha256=KHsRYFZ38ff3AkkqIQu45883ovgKOJn_fZfnTNy7HWY,2952
|
|
87
87
|
port_ocean/core/integrations/mixins/__init__.py,sha256=FA1FEKMM6P-L2_m7Q4L20mFa4_RgZnwSRmTCreKcBVM,220
|
|
88
88
|
port_ocean/core/integrations/mixins/events.py,sha256=Ddfx2L4FpghV38waF8OfVeOV0bHBxNIgjU-q5ffillI,2341
|
|
89
89
|
port_ocean/core/integrations/mixins/handler.py,sha256=mZ7-0UlG3LcrwJttFbMe-R4xcOU2H_g33tZar7PwTv8,3771
|
|
@@ -111,7 +111,7 @@ port_ocean/log/sensetive.py,sha256=wkyvkKMbyLTjZDSbvvLHL9bv4RvD0DPAyL3uWSttUOA,2
|
|
|
111
111
|
port_ocean/middlewares.py,sha256=6GrhldYAazxSwK2TbS-J28XdZ-9wO3PgCcyIMhnnJvI,2480
|
|
112
112
|
port_ocean/ocean.py,sha256=nRTTh6faPrt77ozvKBFk6eCNxwzKcTDzJ4KPgpO4VRk,4304
|
|
113
113
|
port_ocean/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
114
|
-
port_ocean/run.py,sha256=
|
|
114
|
+
port_ocean/run.py,sha256=IYo3R0DChb0-Uqs_WU8f5sk_ZBrv1Xjb-PHyE5IRAYw,1835
|
|
115
115
|
port_ocean/sonar-project.properties,sha256=X_wLzDOkEVmpGLRMb2fg9Rb0DxWwUFSvESId8qpvrPI,73
|
|
116
116
|
port_ocean/utils/__init__.py,sha256=KMGnCPXZJbNwtgxtyMycapkDz8tpSyw23MSYT3iVeHs,91
|
|
117
117
|
port_ocean/utils/async_http.py,sha256=arnH458TExn2Dju_Sy6pHas_vF5RMWnOp-jBz5WAAcE,1226
|
|
@@ -122,8 +122,8 @@ port_ocean/utils/queue_utils.py,sha256=KWWl8YVnG-glcfIHhM6nefY-2sou_C6DVP1VynQwz
|
|
|
122
122
|
port_ocean/utils/repeat.py,sha256=0EFWM9d8lLXAhZmAyczY20LAnijw6UbIECf5lpGbOas,3231
|
|
123
123
|
port_ocean/utils/signal.py,sha256=K-6kKFQTltcmKDhtyZAcn0IMa3sUpOHGOAUdWKgx0_E,1369
|
|
124
124
|
port_ocean/version.py,sha256=UsuJdvdQlazzKGD3Hd5-U7N69STh8Dq9ggJzQFnu9fU,177
|
|
125
|
-
port_ocean-0.
|
|
126
|
-
port_ocean-0.
|
|
127
|
-
port_ocean-0.
|
|
128
|
-
port_ocean-0.
|
|
129
|
-
port_ocean-0.
|
|
125
|
+
port_ocean-0.6.0.dist-info/LICENSE.md,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
|
126
|
+
port_ocean-0.6.0.dist-info/METADATA,sha256=1qQJtxP7GAgYR5HaAhatoIKdkLF7Cq75wSGi11fbrUw,6553
|
|
127
|
+
port_ocean-0.6.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
128
|
+
port_ocean-0.6.0.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
|
|
129
|
+
port_ocean-0.6.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|