port-ocean 0.18.8__py3-none-any.whl → 0.18.9__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.
@@ -8,6 +8,7 @@ from port_ocean.cli.commands.main import print_logo, console
8
8
  from port_ocean.core.defaults import clean_defaults
9
9
  from port_ocean.ocean import Ocean
10
10
  from port_ocean.utils.misc import load_module
11
+ from port_ocean.utils.signal import init_signal_handler
11
12
  from .group import defaults
12
13
 
13
14
 
@@ -27,12 +28,20 @@ from .group import defaults
27
28
  is_flag=True,
28
29
  help="Wait for the migration to finish. when force is set to true.",
29
30
  )
30
- def clean(path: str, force: bool, wait: bool) -> None:
31
+ @click.option(
32
+ "-d",
33
+ "--destroy",
34
+ "destroy",
35
+ is_flag=True,
36
+ help="Destroy the integration after cleaning the defaults.",
37
+ )
38
+ def clean(path: str, force: bool, wait: bool, destroy: bool) -> None:
31
39
  """
32
40
  Clean defaults of the integration from the .port/resources PATH.
33
41
 
34
42
  PATH: Path to the integration. If not provided, the current directory will be used.
35
43
  """
44
+ init_signal_handler()
36
45
  print_logo()
37
46
 
38
47
  console.print("Cleaning blueprints and configurations! ⚓️")
@@ -52,5 +61,9 @@ def clean(path: str, force: bool, wait: bool) -> None:
52
61
  )
53
62
 
54
63
  clean_defaults(
55
- app.integration.AppConfigHandlerClass.CONFIG_CLASS, app.config, force, wait
64
+ app.integration.AppConfigHandlerClass.CONFIG_CLASS,
65
+ app.config,
66
+ force,
67
+ wait,
68
+ destroy,
56
69
  )
@@ -178,3 +178,18 @@ class IntegrationClientMixin:
178
178
  )
179
179
  handle_status_code(response, should_log=should_log)
180
180
  logger.debug(f"Examples for kind {kind} successfully ingested")
181
+
182
+ async def _delete_current_integration(self) -> httpx.Response:
183
+ logger.info(f"Deleting integration with id: {self.integration_identifier}")
184
+ response = await self.client.delete(
185
+ f"{self.auth.api_url}/integration/{self.integration_identifier}",
186
+ headers=await self.auth.headers(),
187
+ )
188
+ return response
189
+
190
+ async def delete_current_integration(
191
+ self, should_raise: bool = True, should_log: bool = True
192
+ ) -> dict[str, Any]:
193
+ response = await self._delete_current_integration()
194
+ handle_status_code(response, should_raise, should_log)
195
+ return response.json()
@@ -18,10 +18,11 @@ def clean_defaults(
18
18
  integration_config: IntegrationConfiguration,
19
19
  force: bool,
20
20
  wait: bool,
21
+ destroy: bool,
21
22
  ) -> None:
22
23
  try:
23
24
  asyncio.new_event_loop().run_until_complete(
24
- _clean_defaults(config_class, integration_config, force, wait)
25
+ _clean_defaults(config_class, integration_config, force, wait, destroy)
25
26
  )
26
27
 
27
28
  except Exception as e:
@@ -33,6 +34,7 @@ async def _clean_defaults(
33
34
  integration_config: IntegrationConfiguration,
34
35
  force: bool,
35
36
  wait: bool,
37
+ destroy: bool,
36
38
  ) -> None:
37
39
  port_client = ocean.port_client
38
40
  is_exists = await is_integration_exists(port_client)
@@ -54,9 +56,9 @@ async def _clean_defaults(
54
56
  )
55
57
  )
56
58
 
57
- if not force:
59
+ if not force and not destroy:
58
60
  logger.info(
59
- "Finished deleting blueprints and configurations! ⚓️",
61
+ "Finished deleting blueprints! ⚓️",
60
62
  )
61
63
  return None
62
64
 
@@ -73,6 +75,19 @@ async def _clean_defaults(
73
75
  for migration_id in migration_ids
74
76
  )
75
77
  )
78
+ if not destroy:
79
+ logger.info(
80
+ "Migrations completed successfully! ⚓️",
81
+ )
82
+ return None
83
+
84
+ result = await ocean.port_client.delete_current_integration()
85
+ if result.get("ok"):
86
+ logger.info(
87
+ "Blueprints deleted, migrations completed, and integration destroyed successfully! ⚓️",
88
+ )
89
+ return None
90
+
76
91
  except httpx.HTTPStatusError as e:
77
92
  logger.error(f"Failed to delete blueprints: {e.response.text}.")
78
93
  raise e
@@ -102,7 +102,7 @@ class HttpEntitiesStateApplier(BaseEntitiesStateApplier):
102
102
  await self._safe_delete(diff.deleted, kept_entities, user_agent_type)
103
103
  else:
104
104
  logger.info(
105
- f"Skipping deletion of entities with delition rate {deletion_rate}",
105
+ f"Skipping deletion of entities with deletion rate {deletion_rate}",
106
106
  deletion_rate=deletion_rate,
107
107
  deleting_entities=len(diff.deleted),
108
108
  total_entities=len(entities),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: port-ocean
3
- Version: 0.18.8
3
+ Version: 0.18.9
4
4
  Summary: Port Ocean is a CLI tool for managing your Port projects.
5
5
  Home-page: https://app.getport.io
6
6
  Keywords: ocean,port-ocean,port
@@ -12,7 +12,7 @@ port_ocean/cli/__init__.py,sha256=ZjTGS305llhbjC2BH2KkVj34gCASBGwqc5HZEO_0T_Q,32
12
12
  port_ocean/cli/cli.py,sha256=RvWTELEn5YFw9aM0vaNqm5YqZZrL50ILaBs27ptiGl0,57
13
13
  port_ocean/cli/commands/__init__.py,sha256=Y9Q6jeYw_ZAZ-mdfE_5DZTdS2KHhieQZoUTggk_AkwM,369
14
14
  port_ocean/cli/commands/defaults/__init___.py,sha256=5OKgakO79bTbplFv1_yWCrw1x_JJqSdRXAHHqKSuEpQ,88
15
- port_ocean/cli/commands/defaults/clean.py,sha256=258rOSC1xGT-NTBIkv-V8HTY57ZipnOD-gV5yEenut0,1570
15
+ port_ocean/cli/commands/defaults/clean.py,sha256=hmWNqbiYSxUu2F2EoxkKm5UiZK-g02TSeEiO-8eGIpk,1851
16
16
  port_ocean/cli/commands/defaults/dock.py,sha256=pFtHrU_LTvb5Ddrzj09Wxy-jg1Ym10wBYD-0tpDRugE,1104
17
17
  port_ocean/cli/commands/defaults/group.py,sha256=hii_4CYoQ7jSMePbnP4AmruO_RKWCUcoV7dXXBlZafc,115
18
18
  port_ocean/cli/commands/list_integrations.py,sha256=DVVioFruGUE-_v6UUHlcemWNN6RlWwCrf1X4HmAXsf8,1134
@@ -50,7 +50,7 @@ port_ocean/clients/port/client.py,sha256=OaNeN3U7Hw0tK4jYE6ESJEPKbTf9nGp2jcJVq00
50
50
  port_ocean/clients/port/mixins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
51
  port_ocean/clients/port/mixins/blueprints.py,sha256=POBl4uDocrgJBw4rvCAzwRcD4jk-uBL6pDAuKMTajdg,4633
52
52
  port_ocean/clients/port/mixins/entities.py,sha256=PJzVZTBW_OheFRGPRCZ6yPbVGEAKsMO9CNDNJUI1l48,10770
53
- port_ocean/clients/port/mixins/integrations.py,sha256=cOmHdR0NdU8dXMD-5w3OpSEPPbaND0jSjJ4BGcHDsJQ,6900
53
+ port_ocean/clients/port/mixins/integrations.py,sha256=R7ZTdU7UKh1IHOqbOJzK76c_JwAyEosRvIWWs4PO_8k,7543
54
54
  port_ocean/clients/port/mixins/migrations.py,sha256=A6896oJF6WbFL2WroyTkMzr12yhVyWqGoq9dtLNSKBY,1457
55
55
  port_ocean/clients/port/mixins/organization.py,sha256=fCo_ZS8UlQXsyIx-odTuWkbnfcYmVnQfIsSyJuPOPjM,1031
56
56
  port_ocean/clients/port/retry_transport.py,sha256=PtIZOAZ6V-ncpVysRUsPOgt8Sf01QLnTKB5YeKBxkJk,1861
@@ -68,7 +68,7 @@ port_ocean/context/ocean.py,sha256=-T8Z_xcUNMeobr33TTABiOQjxC4KCVvVrP0IytRfen8,6
68
68
  port_ocean/context/resource.py,sha256=yDj63URzQelj8zJPh4BAzTtPhpKr9Gw9DRn7I_0mJ1s,1692
69
69
  port_ocean/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
70
70
  port_ocean/core/defaults/__init__.py,sha256=8qCZg8n06WAdMu9s_FiRtDYLGPGHbOuS60vapeUoAks,142
71
- port_ocean/core/defaults/clean.py,sha256=TOVe5b5FAjFspAkQuKA70k2BClCEFbrQ3xgiAoKXKYE,2427
71
+ port_ocean/core/defaults/clean.py,sha256=_rL-NCl6Q_x3lUxDW5ACOM27IYilTCWl6ISUfRleuL0,2891
72
72
  port_ocean/core/defaults/common.py,sha256=zJsj7jvlqIMLGXhdASUlbKS8GIAf-FDKKB0O7jB6nx0,4166
73
73
  port_ocean/core/defaults/initialize.py,sha256=IYgc6XS5ARdcPM4IQrCSi4cdAomHxJVnP_OWOU9f05U,10382
74
74
  port_ocean/core/event_listener/__init__.py,sha256=T3E52MKs79fNEW381p7zU9F2vOMvIiiTYWlqRUqnsg0,1135
@@ -84,7 +84,7 @@ port_ocean/core/handlers/base.py,sha256=cTarblazu8yh8xz2FpB-dzDKuXxtoi143XJgPbV_
84
84
  port_ocean/core/handlers/entities_state_applier/__init__.py,sha256=kgLZDCeCEzi4r-0nzW9k78haOZNf6PX7mJOUr34A4c8,173
85
85
  port_ocean/core/handlers/entities_state_applier/base.py,sha256=5wHL0icfFAYRPqk8iV_wN49GdJ3aRUtO8tumSxBi4Wo,2268
86
86
  port_ocean/core/handlers/entities_state_applier/port/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
87
- port_ocean/core/handlers/entities_state_applier/port/applier.py,sha256=6YketOyFDYrqK9tGM7FWZLO0bTXiYz0lQB-u3dyJvWw,6271
87
+ port_ocean/core/handlers/entities_state_applier/port/applier.py,sha256=F9TxWJWtFOtgslaAB37WCKaGNkr_al0HDXFqNrEMbaU,6271
88
88
  port_ocean/core/handlers/entities_state_applier/port/get_related_entities.py,sha256=1zncwCbE-Gej0xaWKlzZgoXxOBe9bgs_YxlZ8QW3NdI,1751
89
89
  port_ocean/core/handlers/entities_state_applier/port/order_by_entities_dependencies.py,sha256=lyv6xKzhYfd6TioUgR3AVRSJqj7JpAaj1LxxU2xAqeo,1720
90
90
  port_ocean/core/handlers/entity_processor/__init__.py,sha256=FvFCunFg44wNQoqlybem9MthOs7p1Wawac87uSXz9U8,156
@@ -175,8 +175,8 @@ port_ocean/utils/repeat.py,sha256=0EFWM9d8lLXAhZmAyczY20LAnijw6UbIECf5lpGbOas,32
175
175
  port_ocean/utils/signal.py,sha256=mMVq-1Ab5YpNiqN4PkiyTGlV_G0wkUDMMjTZp5z3pb0,1514
176
176
  port_ocean/utils/time.py,sha256=pufAOH5ZQI7gXvOvJoQXZXZJV-Dqktoj9Qp9eiRwmJ4,1939
177
177
  port_ocean/version.py,sha256=UsuJdvdQlazzKGD3Hd5-U7N69STh8Dq9ggJzQFnu9fU,177
178
- port_ocean-0.18.8.dist-info/LICENSE.md,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
179
- port_ocean-0.18.8.dist-info/METADATA,sha256=_zFxUsljeCQq392DWaZNS5kE4DK4jwZyi1w3CGt1f7U,6669
180
- port_ocean-0.18.8.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
181
- port_ocean-0.18.8.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
182
- port_ocean-0.18.8.dist-info/RECORD,,
178
+ port_ocean-0.18.9.dist-info/LICENSE.md,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
179
+ port_ocean-0.18.9.dist-info/METADATA,sha256=wNsXnfPpKx_dLVdrt9CSVl8oLrrHNM4-T0y6j27iHM4,6669
180
+ port_ocean-0.18.9.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
181
+ port_ocean-0.18.9.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
182
+ port_ocean-0.18.9.dist-info/RECORD,,