diff --git a/.vscode/launch.json b/.vscode/launch.json index 6b4bc755e4..f78f55748f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,6 +1,17 @@ { "version": "0.2.0", "configurations": [ + { + "console": "integratedTerminal", + "cwd": "${workspaceFolder}/integrations/jira", + "envFile": "${workspaceFolder}/integrations/jira/.env", + "justMyCode": true, + "name": "Run jira integration", + "program": "${workspaceFolder}/integrations/jira/debug.py", + "python": "${workspaceFolder}/integrations/jira/.venv/bin/python", + "request": "launch", + "type": "debugpy" + }, { "console": "integratedTerminal", "cwd": "${workspaceFolder}/integrations/snyk", diff --git a/CHANGELOG.md b/CHANGELOG.md index af9b7abbd4..f0b69ef4d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,16 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm +## 0.17.7 (2025-01-08) + +### Bug Fixes + +- Fixed a bug where creating an integration with WEBHOOKS_ONLY event listener failed. + +### Improvements + +- Added jira integration running config to vscode. + ## 0.17.6 (2025-01-08) ### Bug Fixes diff --git a/port_ocean/core/defaults/initialize.py b/port_ocean/core/defaults/initialize.py index 1ae1a49cee..624e514db4 100644 --- a/port_ocean/core/defaults/initialize.py +++ b/port_ocean/core/defaults/initialize.py @@ -68,7 +68,7 @@ async def _initialize_required_integration_settings( ) integration = await port_client.create_integration( integration_config.integration.type, - integration_config.event_listener.to_request(), + integration_config.event_listener.get_changelog_destination_details(), port_app_config=default_mapping, ) elif not integration.get("config"): @@ -77,7 +77,7 @@ async def _initialize_required_integration_settings( ) integration = await port_client.patch_integration( integration_config.integration.type, - integration_config.event_listener.to_request(), + integration_config.event_listener.get_changelog_destination_details(), port_app_config=default_mapping, ) except httpx.HTTPStatusError as err: @@ -85,8 +85,10 @@ async def _initialize_required_integration_settings( raise err logger.info("Checking for diff in integration configuration") - changelog_destination = integration_config.event_listener.to_request().get( - "changelog_destination" + changelog_destination = ( + integration_config.event_listener.get_changelog_destination_details().get( + "changelog_destination" + ) ) if ( integration.get("changelogDestination") != changelog_destination diff --git a/port_ocean/core/event_listener/base.py b/port_ocean/core/event_listener/base.py index 9c9821ccf8..4c1307b49c 100644 --- a/port_ocean/core/event_listener/base.py +++ b/port_ocean/core/event_listener/base.py @@ -78,8 +78,16 @@ class EventListenerSettings(BaseOceanModel, extra=Extra.allow): type: str should_resync: bool = True - def to_request(self) -> dict[str, Any]: + def get_changelog_destination_details(self) -> dict[str, Any]: """ - Converts the Settings object to a dictionary representation (request format). + Returns the changelog destination configuration for the event listener. + By default, returns an empty dict. Only KAFKA and WEBHOOK event listeners need to override this + to provide their specific changelog destination details. + + Returns: + dict[str, Any]: The changelog destination configuration. For example: + - KAFKA returns {"type": "KAFKA"} + - WEBHOOK returns {"type": "WEBHOOK", "url": "https://example.com/resync"} + - Other event listeners return {} """ - return {"type": self.type} + return {} diff --git a/port_ocean/core/event_listener/http.py b/port_ocean/core/event_listener/http.py index ca9bd4a3cb..67e3d34292 100644 --- a/port_ocean/core/event_listener/http.py +++ b/port_ocean/core/event_listener/http.py @@ -27,9 +27,17 @@ class HttpEventListenerSettings(EventListenerSettings): type: Literal["WEBHOOK"] app_host: AnyHttpUrl = Field(..., sensitive=True) - def to_request(self) -> dict[str, Any]: + def get_changelog_destination_details(self) -> dict[str, Any]: + """ + Returns the changelog destination configuration for the webhook event listener. + For webhook event listeners, this specifies the URL where changelog events should be sent. + + Returns: + dict[str, Any]: A dictionary with the webhook URL where changelog events should be sent, + constructed by appending "/resync" to the app_host. + """ return { - **super().to_request(), + "type": self.type, "url": self.app_host + "/resync", } diff --git a/port_ocean/core/event_listener/kafka.py b/port_ocean/core/event_listener/kafka.py index 9efb7c9874..0082ea336e 100644 --- a/port_ocean/core/event_listener/kafka.py +++ b/port_ocean/core/event_listener/kafka.py @@ -46,6 +46,19 @@ class KafkaEventListenerSettings(EventListenerSettings): kafka_security_enabled: bool = True consumer_poll_timeout: int = 1 + def get_changelog_destination_details(self) -> dict[str, Any]: + """ + Returns the changelog destination configuration for the Kafka event listener. + For Kafka event listeners, this specifies that changelog events should be sent via Kafka. + + Returns: + dict[str, Any]: A dictionary with type "KAFKA" to indicate that changelog events + should be sent through the Kafka message bus. + """ + return { + "type": self.type, + } + class KafkaEventListener(BaseEventListener): """ diff --git a/port_ocean/core/event_listener/once.py b/port_ocean/core/event_listener/once.py index 9952b19f32..a3bf56a4e2 100644 --- a/port_ocean/core/event_listener/once.py +++ b/port_ocean/core/event_listener/once.py @@ -23,9 +23,6 @@ class OnceEventListenerSettings(EventListenerSettings): type: Literal["ONCE"] - def to_request(self) -> dict[str, Any]: - return {} - class OnceEventListener(BaseEventListener): """ diff --git a/port_ocean/core/event_listener/polling.py b/port_ocean/core/event_listener/polling.py index c7fef4b8e0..025b406d67 100644 --- a/port_ocean/core/event_listener/polling.py +++ b/port_ocean/core/event_listener/polling.py @@ -27,9 +27,6 @@ class PollingEventListenerSettings(EventListenerSettings): resync_on_start: bool = True interval: int = 60 - def to_request(self) -> dict[str, Any]: - return {} - class PollingEventListener(BaseEventListener): """ diff --git a/pyproject.toml b/pyproject.toml index ab47269d16..12cb73ea91 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "port-ocean" -version = "0.17.6" +version = "0.17.7" description = "Port Ocean is a CLI tool for managing your Port projects." readme = "README.md" homepage = "https://app.getport.io"